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

Hi Monks.

How can I force the UserAgent to use old HTTP 1.0 protocol instead of standard used 1.1?

Best regards,
Andreas

Replies are listed 'Best First'.
Re: LWP and force protocol 1.0
by valdez (Monsignor) on Nov 26, 2002 at 11:36 UTC

    You should use protocol method of HTTP::Request, which is inherited from HTTP::Message. The resulting code should be something like this:

    #!/usr/bin/perl use LWP::UserAgent; $ua = LWP::UserAgent->new; $ua->agent("$0/0.1 " . $ua->agent); $req = HTTP::Request->new(GET => 'http://www.perlmonks.org/'); # here is what you need $req->protocol('HTTP/1.0'); $res = $ua->request($req); if ($res->is_success) { print $res->content; } else { print "Error: " . $res->status_line . "\n"; }

    HTH, Valerio

Re: LWP and force protocol 1.0
by Zaxo (Archbishop) on Nov 26, 2002 at 11:42 UTC

    The HTTP::Request object you set up is a subclass of HTTP::Message, which has the protocol() method. Use it like so: $request->protocol( 'HTTP/1.0' );

    After Compline,
    Zaxo

Re: LWP and force protocol 1.0
by rasta (Hermit) on Nov 26, 2002 at 11:34 UTC
    HTTP::Request is a subclass of HTTP::Message and therefore inherits its methods.
    HTTP::Message has method protocol() sets the HTTP protocol used for the message. The protocol() is a string like HTTP/1.0 or HTTP/1.1.
    -- Yuriy Syrota