Domanda

Getting a 500 server error trying to connect to a Microsoft-HTTPAPI/2.0 server using perl LWP. Can successfully connect using browser. Only difference I see is browser issues HTTP/1.0 protocol vs LWP HTTP/1.1. So I tried forcing LWP to use the older protocol without success. I found examples for setting this protocol but packet examination with Wireshark still shows HTTP/1.1. What have I missed here. Using Active Perl v5.16.1.

#! C:\Perl64\bin\perl.exe
use strict;
use warnings;
use LWP::UserAgent;
use HTTP::Request;
use HTTP::Request::Common;
my $ua = new LWP::UserAgent(keep_alive=>1);
# trying to force HTTP/1.0
push(@LWP::Protocol::http::EXTRA_SOCK_OPTS, PeerHTTPVersion => "1.0");
my $response = $ua->request(GET "http://google.com");
È stato utile?

Soluzione

This will make LWP specify HTTP/1.0.

my $request = GET "http://google.com";
$request->protocol('HTTP/1.0');
my $response = $ua->request($request);
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top