Perl Error when requesting proxy to https site. AnyEvent status 596

198 views Asked by At

when requesting through a proxy that supports https to https site. The error 'Reason' => 'ssl23_get_server_hello comes: unknown protocol', 'Status' => 596,

I use the AnyEvent library, I suspect that the problem with the connect request, but I cannot solve it at all, I will be very grateful for the hint.

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();

suspect that the tcp_connect method is also needed, but I don’t understand how to configure it.

So proxy works for LWP

require LWP::UserAgent;

my $ua = LWP::UserAgent->new;
$ua->timeout(10);
$ua->proxy(['https', 'http'], 'http://XXX:[email protected]: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;
}

Unfortunately, I can not write a full proxy, because it is paid. But if without him absolutely nothing, then I can write.

0

There are 0 answers