作者热门文章
- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
尝试使用 perl LWP 连接到 Microsoft-HTTPAPI/2.0 服务器时出现 500 服务器错误。使用浏览器可以成功连接。我看到的唯一区别是浏览器问题 HTTP/1.0 协议(protocol)与 LWP HTTP/1.1。所以我尝试强制 LWP 使用旧协议(protocol)但没有成功。我找到了设置此协议(protocol)的示例,但使用 Wireshark 进行的数据包检查仍然显示 HTTP/1.1。我在这里错过了什么。使用 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");
最佳答案
这将使 LWP 指定 HTTP/1.0。
my $request = GET "http://google.com";
$request->protocol('HTTP/1.0');
my $response = $ua->request($request);
关于Perl LWP 尝试将 peer_http_version 设置为 HTTP/1.0,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12842906/
尝试使用 perl LWP 连接到 Microsoft-HTTPAPI/2.0 服务器时出现 500 服务器错误。使用浏览器可以成功连接。我看到的唯一区别是浏览器问题 HTTP/1.0 协议(prot
我是一名优秀的程序员,十分优秀!