Subject: | Resolver doesn't delete request when timeout occure in HTTP::Client |
When resolver (by different reason) don't resolve quickly, and timeout
fire in Component::Client::HTTP I receive response with 408, but program
doesn't exit. Because resolver doesn't delete request.
Subject: | for_cpan2.pl |
#!/usr/bin/perl -w
use utf8;
use strict;
use warnings;
use Data::Dumper;
use POE 1.350;
use POE::Component::Client::HTTP 0.944;
use POE::Component::Client::Keepalive 0.270;
use HTTP::Request::Common qw(GET HEAD);
use HTTP::Cookies;
$SIG{__WARN__} = sub {
my $str = shift;
warn scalar(localtime)." $str";
};
my $pool = POE::Component::Client::Keepalive->new(
keep_alive => 3,
max_open => 2,
max_per_host => 2,
timeout => 7,
resolver => POE::Component::Resolver->new(
max_resolvers => 1,
idle_timeout => 11,
sidecar_program => [
'/usr/bin/perl',
(map { "-I$_" } @INC),
'-MPOE::Component::Resolver::Sidecar',
'-e', 'sleep(25); POE::Component::Resolver::Sidecar->main()'
]
),
);
POE::Component::Client::HTTP->spawn(
Alias => 'ua',
FollowRedirects => 3,
Timeout => 1,
MaxSize => 1024,
Agent => '',
ConnectionManager => $pool,
Streaming => 0,
CookieJar => HTTP::Cookies->new(),
);
POE::Session->create(
inline_states => {
_start => sub {
my $header = [TE => 'chunked,identity', Connection => "close"];
my $domain = 'localhost:36333';
my $url = "http://$domain/";
my $request = HTTP::Request->new( 'GET', $url, $header);
$poe_kernel->post( "ua" => "request", "response", $request, {domain=>$domain});
},
_stop => sub {},
response => \&response,
},
);
POE::Kernel->run();
warn 1;
exit;
sub response {
my ($request_packet, $response_packet) = @_[ARG0, ARG1];
my $http_request = $request_packet->[0];
my $tag = $request_packet->[1];
my $http_response = $response_packet->[0];
warn $http_response->status_line;
#warn Dumper $tag;
#warn Dumper $http_response;
}