Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
I'm a newbie to LWP and trying to get my HTTP headers to properly emulate my browser. However, LWP keeps adding a TE header which I want to get rid of.
So far I have:
The output is:#!/usr/bin/perl use warnings; use strict; use LWP::UserAgent; # this page just prints the headers sent by the client my $url = 'http://localhost/go.php'; # initialize browser and set user agent my $browser = LWP::UserAgent->new(); $browser->agent('Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)'); # create new http request, clear headers and add a new header my $request = HTTP::Request->new(GET => $url); $request->clear; $request->header('Connection' => 'keep-alive'); # print the http headers before making the request my $headers = $request->headers_as_string; print "Headers before http request are:\n"; print "$headers"; # send the http request and print the headers echoed back by $url my $response = $browser->request($request); my $contents = $response->decoded_content; print "Returned headers are:\n"; print "$contents";
Why is LWP adding the TE header and the extra parts to the connection header? How can I stop this behaviour?Headers before http request are: Connection: keep-alive User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1) Returned headers are: Connection: keep-alive, TE, close Host: localhost TE: deflate,gzip;q=0.3 User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: LWP::UserAgent adding unwanted TE header
by Corion (Patriarch) on Oct 11, 2019 at 15:56 UTC | |
Re: LWP::UserAgent adding unwanted TE header
by jdtoronto (Prior) on Jul 05, 2006 at 15:06 UTC | |
Re: LWP::UserAgent adding unwanted TE header
by shmem (Chancellor) on Jul 05, 2006 at 10:57 UTC | |
by Anonymous Monk on Jul 05, 2006 at 11:11 UTC | |
by shmem (Chancellor) on Jul 05, 2006 at 12:20 UTC | |
by Anonymous Monk on Jul 05, 2006 at 22:32 UTC |
Back to
Seekers of Perl Wisdom