AnyEvent-HTTP-Socks
view release on metacpan or search on metacpan
$loop->begin;
http_get "http://$h_host:$h_port/unknown", socks => "socks5://$s3_host:$s3_port", sub {
ok(time()-$start<3, "Socks5 delay=1");
is($_[0], 'UNKNOWN', 'response over Socks5');
$loop->end;
};
$loop->begin;
http_get "http://$h_host:$h_port/", timeout => 3, socks => "socks4://$s4_host:$s4_port", sub {
is($_[1]->{Status}, 595, 'Timeout');
$loop->end;
};
$loop->begin;
http_get "http://$h_host:$h_port/", socks => "socks5://$s3_host:$s3_port -> socks4://$s1_host:$s1_port", sub {
is($_[0], 'ROOT', 'socks5 -> socks4 chain');
$loop->end;
};
$loop->begin;
or next;
my $subchild = fork();
die 'subfork: ', $! unless defined $subchild;
if ($subchild == 0) {
my ($cmd, $host, $port) = @{$client->command()};
if($cmd == CMD_CONNECT)
{ # connect
my $socket = "$IO::Socket::Socks::SOCKET_CLASS"->new(PeerHost => $host, PeerPort => $port, Timeout => 10);
if ($delay{reply}) {
sleep $delay{reply};
}
if($socket)
{
# request granted
$client->command_reply($version == 4 ? REQUEST_GRANTED : REPLY_SUCCESS, $socket->sockhost, $socket->sockport);
}
else
{
( run in 0.228 second using v1.01-cache-2.11-cpan-4d50c553e7e )