Subject: | 408 instead of 500 |
I have two request to the server.
When I try to connect to server(server shut down) first request - got
response "Connection to localhost:36333 failed: connect error 111:
Connection refused", but the second - "Connection to localhost:36333
failed: timeout"
Subject: | ht.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.268;
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 => 1,
max_per_host => 2,
timeout => 7,
resolver => POE::Component::Resolver->new(
max_resolvers => 1,
idle_timeout => 11,
),
);
POE::Component::Client::HTTP->spawn(
Alias => 'ua',
FollowRedirects => 3,
Timeout => 13,
MaxSize => 1024,
Agent => '',
ConnectionManager => $pool,
Streaming => 0,
CookieJar => HTTP::Cookies->new(),
);
foreach my $i (1..2) {
POE::Session->create(
inline_states => {
_start => sub {
my $header = [TE => 'chunked,identity', Connection => "close"];
my $domain = 'localhost:36333';
my $url = "http://$domain/$i";
my $request = HTTP::Request->new( 'GET', $url, $header);
$poe_kernel->post( "ua" => "request", "response", $request, {domain=>$domain, i => $i});
},
_stop => sub {},
response => \&response,
},
);
}
POE::Kernel->run();
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 Dumper $http_response;
}