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:
#!/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";
The output is:
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)
Why is LWP adding the TE header and the extra parts to the connection header? How can I stop this behaviour?