我无法对https网站使用perl模块LWP :: Parallel :: UserAgent。以下是我使用的代码:
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div class="timer-1" data-seconds-left="5"></div>
它适用于http ,但是如果您尝试通过https网站更改$ url,则会失败。
错误代码:500 消息:在/usr/share/perl5/LWP/Protocol/https.pm行119处无法通过包“ IO :: Socket :: INET”找到对象方法“ get_cipher”
对于https://www.stackoverflow.com:
错误代码:402 消息:阅读回复时出现意外的EOF
系统是最新的。有建议吗?
谢谢!
答案 0 :(得分:2)
从您的代码中:
$pua->nonblock('true');
当查看LWP :: Parallel :: UserAgent的代码时,对HTTPS的无阻塞支持似乎已被破坏:https
支持在LWP :: Parallel :: Protocol :: https中实现来自doing the actual connection的LWP :: Parallel :: Protocol :: http。 sub _connect中的相关代码:
103 unless ($nonblock) {
104 # perform good ol' blocking behavior
105 #
106 # this method inherited from LWP::Protocol::http
107 $socket = $self->_new_socket($host, $port, $timeout);
108 # currently empty function in LWP::Protocol::http
109 # $self->_check_sock($request, $socket);
110 } else {
111 # new non-blocking behavior
...
116 $socket =
117 IO::Socket::INET->new(Proto => 'tcp', # Timeout => $timeout,
118 $self->_extra_sock_opts ($host, $port));
可以看到,对于(默认)阻塞情况,代码使用LWP::Protocol::http
的功能,但是对于非阻塞情况,它直接使用IO::Socket::INET
-而不是IO::Socket::SSL
HTTPS。但是LWP :: Protocol :: http(稍后使用)实际上期望使用SSL套接字并尝试在其上调用get_cipher
。这会导致您看到错误:
无法在/usr/share/perl5/LWP/Protocol/https.pm第119行通过包“ IO :: Socket :: INET”找到对象方法“ get_cipher”
当不使用非阻塞支持时,该代码似乎可以工作。
关于该模块中的HTTPS,请参见README.SSL:
** DISCLAIMER: https support is pretty buggy as of now. i haven't **
** had time to test much of it, so feel free to see if it works **
** for you, but don't expect it to :-)
换句话说:您可能应该使用其他模块来获得对HTTPS的可靠支持。