in reply to Re: Re:* Mechanize and "Not implemented"
in thread Mechanize and "Not implemented"

It turns out that requests using HTTP/1.0 can generate a 501 response from the server. I've gone through several module docs (HTTP::Request, HTTP::Headers, LWP itself), but I haven't found this particular issue addressed.

What would I need to set in the UserAgent object to have it use HTTP/1.1 protocol?

Update: my question appears to be answered here, and it isn't the protocol that is the problem for me.

  • Comment on Using HTTP/1.1 instead of 1.0 (was: Re: Mechanize and "Not implemented")

Replies are listed 'Best First'.
Re: Using HTTP/1.1 instead of 1.0 (was: Re: Mechanize and "Not implemented")
by PodMaster (Abbot) on Nov 20, 2003 at 19:57 UTC
    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.