in reply to LWP::UserAgent Wrongly Uses HTTP/1.1

I waded through some of the LWP::UserAgent code to try and find your answer. I think I found it. Basically, I don't think you can get LWP to do this. The reason (from what I think I understood) is as follows.

LWP::UserAgent seems to only honor the method (i.e. http, https) and uri of the HTTP::Request that you give it. The protocol() method that you are trying to set on the Request (which is actually inherited from HTTP::Message) seems to only be used for setting the protocol of the peer (i.e. web-server) for the HTTP::Response that you get back.

What determines the protocol of the request (which is what you're interested in) is the http_version of the Net::HTTP::Methods object, which the LWP::Protocol::http::Socket (which is how the request is actually sent) inherits from. The crucial bit of code is found in LWP/Protocol/http.pm, in the _new_socket() method, where the socket is created. The call to new() would need to have an argument HTTPVersion => '1.0', which Net::HTTP->new() (Net::HTTP is a sub-class of IO::Socket::INET, FYI) would use to set the request HTTP version to 1.0.

Whew. Hope that made some sense.

--
3dan

  • Comment on Re: LWP::UserAgent Wrongly Uses HTTP/1.1

Replies are listed 'Best First'.
Re: Re: LWP::UserAgent Wrongly Uses HTTP/1.1
by Anonymous Monk on Nov 20, 2003 at 12:31 UTC
    Hmmmm....I see what you're saying I think, but if I set the request object to use 1.0, shouldn't it be calling on LWP::Protocol::http10.pm instead of http.pm?

      Hmm... I did all my investigation on LWP::UserAgent version 2.1 which comes with 5.6.1. Perhaps it's all wrong for the version that comes with 5.8.0. But from looking through the docs, you can get LWP to use http10.pm by setting the PERL_LWP_USE_HTTP_10 environment variable to something TRUE. Perhaps try that, and see if it solves your problem...

      --
      3dan