#!/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";