Subject: | crashes when redirected to invalid URL |
I'm using POE-Component-Client-HTTP-0.947 with perl 5.16.3 on CentOS 6.4 .
http://planet.naga.ph/feed/ redirects to a URL that starts with "htttp:"
The following code crashes and produces a screenful of error messages-
use POE qw(Component::Client::HTTP);
use HTTP::Request;
my (@requests);
my $request = HTTP::Request->new(GET => 'http://planet.naga.ph/feed/');
push @requests, $request;
POE::Component::Client::HTTP->spawn(Alias => 'ua', FollowRedirects => 1);
POE::Session->create(inline_states => { _start => sub { $_[KERNEL]->yield('process_feed') },
process_feed => \&process_feed,
process_response => \&process_response } );
sub process_feed {
return unless (@requests) and (my $request = pop(@requests));
$_[KERNEL]->post('ua', 'request', 'process_response', $request );
}
sub process_response {
my $request = $_[ARG0]->[0];
my $response = $_[ARG1]->[0];
printf("URI: %s\t Status Line: %s\n", $request->uri, $response->status_line);
$_[KERNEL]->yield('process_feed');
}
POE::Kernel->run();