【发布时间】:2023-03-29 08:03:01
【问题描述】:
案例 1: 我的服务器(远程访问没有互联网访问权限)在 443 端口连接到远程服务器。使用 Web 服务 URL,我需要发送 Web 服务请求并接收响应。我能够使用发送请求但无法接收来自远程服务器的响应。 代码: 这是我使用 perl 中的 lwp 代理发送和接收 https 请求的代码
use Data::Dumper;
use LWP::UserAgent;
use HTTP::Status;
use HTTP::Response;
use HTTP::Request::Common;
$ENV{PERL_LWP_SSL_VERIFY_HOSTNAME} = 0;
$LWPUserAgent = new LWP::UserAgent( 'timeout' => '20');
$LWPUserAgent->ssl_opts('verify_hostname' => 0) ;
$WEB_URL="https://webserviceurl.com/Request?Arg1|Arg2|Arg3|Arg4";
$Response = $LWPUserAgent->get($WEB_URL);
print Dumper $Response ;
我使用 Data::Dumper 打印了响应并得到了以下响应。
$VAR1 = bless( {
'_content' => 'Status read failed: at /usr/share/perl5/Net/HTTP/Methods.pm line 269.',
'_rc' => 500,
'_headers' => bless( {
'client-warning' => 'Internal response',
'client-date' => 'Tue, 13 Oct 2015 15:13:21 GMT',
'content-type' => 'text/plain'
}, 'HTTP::Headers' ),
'_msg' => 'Status read failed: ',
'_request' => bless( {
'_content' => '',
'_uri' => bless( do{\(my $o = 'https://webserviceurl.com/Request?Arg1%7Arg2%7Arg3%7Arg4')}, 'URI::https' ),
'_headers' => bless( {
'user-agent' => 'libwww-perl/6.04'
}, 'HTTP::Headers' ),
'_method' => 'GET'
}, 'HTTP::Request' )
}, 'HTTP::Response' );
我在谷歌上搜索了更多关于这个的信息,但我找不到任何关于这个的想法。 我的服务器信息是: 操作系统 - wheezy 7.2 64 位。 perl 5,版本 14,subversion 2 (v5.14.2) 为 x86_64-linux-gnu-thread-multi 构建 LWP::UserAgent - 6.04 HTTP::Response,HTTP::Status,HTTP::Request::Common 版本是 - 6.03。 案例 2:我的服务器(在家庭和互联网访问中)使用我的互联网连接的静态 IP 进行连接。使用我的代理尝试使用下面的代码运行上面的代码。
$LWPUserAgent->proxy('https', 'http://192.168.12.10:3128') ;
I am able to send and receive the https requests using LWP agent and working fine.
My server information are:
OS - squeeze (6.0.6) 32 bit
perl, v5.10.1 (*) built for i486-linux-gnu-thread-multi
LWP::UserAgent - 6.13
HTTP::Response - 5.836
HTTP::Status - 5.817
HTTP::Request::Common - 5.824
I confused of the these things.
1.OS problem
2.Package versions problem
3.whether is it a bug in wheezy
If any one can provide me the correct direction to resolve this it would be highly appreciated.
【问题讨论】:
-
你有什么版本的 Net::HTTP?该错误消息甚至在最新消息中都不存在。
-
鉴于它是 perl
5.10- 已经 6 岁且生命终结,我想它也不是太新的 Net::HTTP 版本。 -
Net::HTTP的版本是6.03
-
在两台服务器中,我都可以使用 LWP::UserAgent 在 http(80 端口)中发送和接收 Web 服务请求。但在 https(443 端口)中,只有我面临这个问题。
标签: linux perl https operating-system lwp-useragent