mifflin has asked for the wisdom of the Perl Monks concerning the following question:

Here is a code snippet where I'm am trying to send a request to another program I have written using HTTP::Deamon.
my $requestHeader = HTTP::Headers->new(); $requestHeader->header('Connection' => 'Keep-Alive'); $requestHeader->header('Content-Type' => 'text/xml; charset=utf-8') +; $requestHeader->header('Content-Length' => length($requestContent)) +; my $request = HTTP::Request->new('POST', $url, $requestHeader, $req +uestContent); $request->protocol('HTTP/1.1'); print $request->headers()->as_string(); my $browser = LWP::UserAgent->new(); my $response = $browser->request($request);
When I run this it prints out
Connection: Keep-Alive
Content-Length: 294
Content-Type: text/xml; charset=utf-8
When my deamon server gets it the headers received become
Connection: Keep-Alive, TE, close
Host: dev:2229
TE: deflate,gzip;q=0.3
User-Agent: libwww-perl/5.69
Content-Length: 294
Content-Type: text/xml; charset=utf-8
When and how is the ", TE, close" being added the the Connection value and how do I stop LWP from doing that?

Replies are listed 'Best First'.
Re: http connection header value problems
by mifflin (Curate) on Apr 28, 2004 at 20:08 UTC
    I think I've discovered the answer.
    It appears that there is a keep_alive option available when creating the user agent object.
    The following change keeps the request() method from closing the connection.
    my $browser = LWP::UserAgent->new(keep_alive => 1);