Perl HTTP Tiny + Socket Socks Wrapper Timeout tidak berfungsi

Saya menggunakan HTTP::Tiny + IO::Socket ::Socks::Wrapper untuk mengirim Permintaan HTTP melalui Proxy SOCKS. Semuanya berfungsi dengan baik kecuali opsi batas waktu. Saat hanya menggunakan IO::Socket::Socks tanpa HTTP::Tiny, batas waktu berfungsi.

Contoh tanpa HTTP::Tiny dan proxy tidak ada untuk memicu batas waktu:

my $t = time;
my $sock = IO::Socket::Socks->new(
    ProxyAddr => '4.5.6.7', 
    ProxyPort => 1080, 
    ConnectAddr => 'www.google.com', 
    ConnectPort => 80, 
    Timeout => 3
) or print "connection failed or timed out\n";

print "time: " . (time - $t) . "\n";

Keluaran:

connection failed or timed out
time: 3.00517201423645

Contoh dengan HTTP::Tiny:

my $t = time;
my $http = wrap_connection(
    HTTP::Tiny->new(timeout => 3), {
        ProxyAddr => '4.5.6.7', 
        ProxyPort => 1080, 
        Timeout => 3
    }
);
my $r = $http->get("http://www.google.com");
print "connection failed or timed out\n" unless $r->{success};
print "time: " . (time - $t) . "\n";

Keluaran:

connection failed or timed out
time: 21.0282030105591

Mengapa contoh kedua tidak habis setelah 3 detik?


person knv17    schedule 23.11.2013    source sumber


Jawaban (1)


Itu adalah bug, yang sekarang tampaknya sudah diperbaiki. Versi baru akan segera diunggah ke CPAN. Dan sekarang Anda bisa mendapatkan versi tetap dari repo github.

person Oleg G    schedule 11.12.2013