hai all,
  
     i tested the folowing proxy.pl prg.
my browser displays cookies not set error. why
when it sends the request to the original server, it
sends connection :close header. why is it so.

Thanks

use strict;
use HTTP::Daemon;
use LWP::UserAgent;
use HTTP::Request;
my($CRLF)="\015\012";
my $d=new HTTP::Daemon
        LocalAddr => 'localhost',

        LocalPort => 8080;
        Reuse=>1;
        Listen=>20;

print "please contact me at\n ";

sub prefix {
              my $now = localtime;

              join "", map { "[$now] [${$}] $_\n" }
split /\n/, join "", @_;
            }

$SIG{__WARN__} = sub { warn prefix @_ };
$SIG{__DIE__} = sub { die prefix @_ };
$SIG{CLD} = $SIG{CHLD} = sub { wait; };
my $agent=new LWP::UserAgent;
while (my $client= $d->accept)
{
   print "connected\n";
   defined (my $pid=fork);
   if ($pid)
   {
      undef($client);

   } else {
      $client->autoflush(1);
      &handler($client);
   }
}



sub handler
{
   my $client=shift;

  while($client)
   {
       my  $req = $client->get_request;
       print $req->url."\n";
       if (!defined $req){exit(0);}
       &fetchres($req,$client);
   }
}

sub fetchres
{
   my ($originreq)=shift;
   my $req=$originreq->clone;
   $req->protocol($originreq->protocol());
   my $res=$agent->request($req);
   chomp (my ($mess)=$res->message);
   my $client=shift;
   $client->send_status_line($res->code,$mess,
$res->protocol);
   print $client
$res->headers_as_string("$CRLF").("$CRLF");
   print $client ${$res->content_ref};

}


__________________________________________________
Do you Yahoo!?
Yahoo! Shopping - Send Flowers for Valentine's Day
http://shopping.yahoo.com

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to