Hello,
I have the following snippet which is a simple proxy. It takes
http-requests, adds a headerfield and forwards it.
==========
if (defined (my $req = $c->get_request)) # received request from connected
client?
{
# print "----- ", ref $req, "\n";
$req->remove_header("Proxy-Connection"); # essential line for this
proxy to work
$req->push_header("Proxy-Authorization" => "Basic $encoded");
$req->push_header("Connection" => "Keep-Alive");
print $req->as_string, "\n";
my $res = $ua->request($req); # perform forward request
# print "----- ", ref $res, ": ";
# print $res->status_line, "\n";
# print $res->as_string, "\n";
# print "-----", "\n";
if (! $res->is_error) # test response on forwarded request
{
$c->send_response($res);
}
}
But, somehow there's a difference in headers which Perl says it will send
(print $req->as_string) and the headers found by a sniffer... The
headerfield 'Connection: Keep-Alive' cannot be found in the sniffer-output,
allthough the field 'Proxy-Authorization: Basic wkI7653B78axyt==' can be
found.... Anybody any idea's why?
Perl-output:
----- HTTP::Request
GET http://www.bruna.nl/ HTTP/1.0
Connection: Keep-Alive
Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg,
application/vnd.ms-
excel, application/msword, application/vnd.ms-powerpoint,
*/*Accept-Language: nl
Host: www.bruna.nl
Proxy-Authorization: Basic bWtsZWVmbWFuOm1hYW5kYWc=
User-Agent: Mozilla/4.0 (compatible; MSIE 5.01; Windows 95)
Cookie: PHPSESSID=a73de71e5438c081c5856baa370ce91d
Sniffer-output:
GET http://www.bruna.nl/ HTTP/1.0
Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg,
application/vnd.ms-excel, application/msword, application/vnd.ms-powerpoint,
*/*
Accept-Language: nl
Host: www.bruna.nl
Proxy-Authorization: Basic bWtsZWVmbWFuOm1hYW5kYWc=
User-Agent: Mozilla/4.0 (compatible; MSIE 5.01; Windows 95)
Thanx in advance,
Marco Kleefman
The Netherlands