通过支持https到https站点的代理进行请求时。错误'原因'=>'ssl23_get_server_hello来了:未知协议','状态'=> 596,
我使用的是AnyEvent库,我怀疑连接请求存在问题,但我根本无法解决,我将非常感谢您的提示。
use strict;
use utf8;
use Data::Dumper;
use AnyEvent::HTTP;
use MIME::Base64;
use AnyEvent::Connector;
my $cookies = {};
my $done = AnyEvent->condvar;
my $request_watcher = http_request(
get => 'https://randomup.ru',
(
keepalive => 1,
persistent => 1,
recurse => 0,
cookie_jar => $cookies,
timeout => 10,
headers => {
'user-agent' => 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3445.2 Safari/537.36',
'accept-encoding' => 'gzip',
'Accept-Language'=> 'en-us,en;q=0.5',
'Accept-Charset'=> 'ISO-8859-1,utf-8;q=0.7,*;q=0.7',
'Proxy-Authorization' => 'Basic ' . encode_base64('XXX' . ':' . 'XXX'),
},
),
on_header => sub {
print STDERR Dumper @_;
return 1;
},
proxy => ['XX.XX.XX.XX', 8000, 'http'],
sub {
print STDERR Dumper @_;
#$done->send;
}
);
$done->recv();
怀疑还需要tcp_connect方法,但是我不知道如何配置它。
因此代理适用于LWP
require LWP::UserAgent;
my $ua = LWP::UserAgent->new;
$ua->timeout(10);
$ua->proxy(['https', 'http'], 'http://XXX:NChD7r@XXX.XXX.38.67:8000');
# $ua->proxy(['https'], 'https://proxy:8080'); # Fails
# $ua->env_proxy; # This also fails.
my $response = $ua->get('https://randomup.ru');
if ($response->is_success) {
print $response->decoded_content; # or whatever
}
else {
die $response->status_line;
}
很遗憾,我无法编写完整的代理,因为它是付费的。但是,如果没有他绝对没有什么,那我可以写信。