Bennett Haselton wrote:
> [Sorry if this is coming through twice.  I unsubbed a while ago, forgot I 
> had unsubbed, posted this question to the list, and got a message back 
> saying it would be queued for moderator approval.  I don't know if the 
> moderators approved this message when I first sent it to the list.  If 
> anybody replied to the list, I didn't see it.]
> 
> How can I see *exactly* what HTTP headers are sent when I create a 
> UserAgent object, a Request object, and make the request using the 
> user-agent?
> 
> e.g. in this code:
>  >>>
> use strict;
> use LWP::UserAgent;
> 
> my $ua = new LWP::UserAgent;
> $ua->agent("Netscape/4.75");
> 
> my $url = 'http://www.yahoo.com/';
> 
> my $req = HTTP::Request->new('GET', $url);
> print "Request headers: " . $req->as_string . "\n";
> my $res = $ua->request($req);
>  >>>
> 
> the $req->as_string part doesn't show the headers that will be sent with 
> the request.  But then, how could it anyway, because there are some 
> headers, like "User-Agent: Netscape/4.75", that would be due to properties 
> I'd set on the UserAgent object, and the Request object would have no way 
> of knowing about them.
> 
>  From using a network sniffer, I know that when I run this code on my PC, 
> the headers it sends out are:
> 
> GET / HTTP/1.1
> TE: deflate,gzip;q=0.3
> Connection: TE, close
> Host: www.yahoo.com
> User-Agent: Netscape/4.75
> 
> However, I know that when I run the script on a UNIX machine, the headers 
> are different, because for some servers, I get different results if I run 
> the perl script to fetch the URL, vs. telnetting to port 80 on the Web 
> server and typing in the headers manually.
> 
> Therefore, I need a way to find out *exactly* what HTTP headers are being 
> sent out by the perl script on the UNIX server when I run the perl script, 
> and I don't have a network sniffer on that machine.  How can I do that?

You could try Tim's sniffer (redirect your url to the sniffer and have the
sniffer set to where you want to go - slide it in the middle):

http://www.schmerg.com/WrapUp.asp?file=HttpSniffer.html


-- 
  ,-/-  __      _  _         $Bill Luebkert    Mailto:[EMAIL PROTECTED]
 (_/   /  )    // //       DBE Collectibles    Mailto:[EMAIL PROTECTED]
  / ) /--<  o // //      Castle of Medieval Myth & Magic http://www.todbe.com/
-/-' /___/_<_</_</_    http://dbecoll.tripod.com/ (Free site for Perl/Lakers)


_______________________________________________
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to