update:I'm of course talking about the latest and greatest (libwww-perl/5.75)
Hmm, by default LWP::UserAgent should be sending a HTTP/1.1 request. LWP::UserAgent contains
if ($ENV{PERL_LWP_USE_HTTP_10}) {
require LWP::Protocol::http10;
LWP::Protocol::implementor('http', 'LWP::Protocol::http10');
eval {
require LWP::Protocol::https10;
LWP::Protocol::implementor('https', 'LWP::Protocol::https10');
};
}
LWP::Protocol::http10 sends HTTP/1.0, where as LWP::Protocol::http
sends HTTP/1.1. Net::HTTP is what's used underneath the hood, and describes this and more (see http_version, peer_http_version). Here's a little demo
use strict;
use warnings;
use LWP;
use LWP::Debug '+';
use Data::Dumper;
my $ua = LWP::UserAgent->new();
$ua->get(shift || 'http://localhost');
# because LWP I<use>s it at runtime
use LWP::Protocol::http;
package LWP::Protocol::http::Socket;
sub format_request {
my $self = shift;
my $ret = $self->SUPER::format_request(@_);
LWP::Debug::trace($ret);
return $ret;
}
__END__
LWP::UserAgent::new: ()
LWP::UserAgent::request: ()
LWP::UserAgent::send_request: GET http://localhost
LWP::UserAgent::_need_proxy: Not proxied
LWP::Protocol::http::request: ()
LWP::Protocol::http::Socket::format_request: GET / HTTP/1.1
TE: deflate,gzip;q=0.3
Connection: TE, close
Host: localhost
User-Agent: libwww-perl/5.75
LWP::Protocol::collect: read 640 bytes
LWP::Protocol::collect: read 854 bytes
LWP::UserAgent::request: Simple response: OK
| MJD says "you can't just make shit up and expect the computer to know what you mean, retardo!" | | I run a Win32 PPM repository for perl 5.6.x and 5.8.x -- I take requests (README). | | ** The third rule of perl club is a statement of fact: pod is sexy. |
|