web proxy 求助

web proxy 求助
1 这个是个 web proxy 要加个 HTTP Authentication,在web browser 和 proxy server 之间,用http protocal 1.0 那位大哥,大姐能帮忙弄下么?


#!/usr/bin/perl
use IO::Socket;
use POSIX;
$port =shift || 6739;
$SIG{CHLD} = \&reaper;
$listening = IO::Socket::INET->new(
Localport => $port,
Reuse => 1,
Listen => 5) or die "$@\n";
while (1)
{
$browser = $listening->accept();
if (fork==0)
{
close($listening);
sysread($browser, $buffer, 4096);
$buffer =~ /Host: ([\w.])+/i;
$host =$1;

$web_server = IO::Socket::INET->new(
PeerAddr=>$host,
PeerPort=>'80') or die "$@\n";
$beffer =~ s/proxy-connecton: keep-alive/Connection: Close/i;
syswrite($web_server, $beffer);
syswrite(STDOUT,"Debug $buffer");

while (sysread($web_server, $sbuffer, 4096)>0)
{
syswrite($browser, $sbuffer);
}
exit;
}
else
{
close($browser);
}
} #while

sub reaper
{
while (($kid= waitpid (-1,WNDHANG))>0)
{
print "Reoped child $kid zombie \n";
}
}