Skip Menu |

This queue is for tickets about the POE-Component-Client-HTTP CPAN distribution.

Report information
The Basics
Id: 25577
Status: resolved
Priority: 0/
Queue: POE-Component-Client-HTTP

Owner: Nobody in particular
Requestors: YKAR [...]

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)

Subject: PoCoCl::HTTP is loosing events when getting bad redirect
Download (untitled) / with headers
text/plain 831b
In function POE::Component::Client::HTTP::_try_redirect response event invoked as $poe_kernel->yield( request => $request, $newrequest, "_redir_".$request->ID, $request->[REQ_PROG_POSTBACK], @proxy ); the second parameter is response event name, but set with PoCoCl::HTTP::Request object so if redirect url is bad (unsupported scheme, empty hostname) _poco_weeble_request function can't send request back because it expect event_name to be a string As solution I propose to check what is the event_name, if it is a string we can send response with kernel->post, if it is a PoCoCl::HTTP::Request object we can use it's postback to send response back to program. I'm sorry, I didn't provide a test case, but I hope I explained the problem well. I've attached patch with my solution.
Subject: patch
Download patch
application/octet-stream 930b

Message body not shown because it is not plain text.

Download (untitled) / with headers
text/plain 640b
I created a test case for this. On unfixed PoCoCl::HTTP it shows: 5 -> _start (from /usr/lib64/perl5/vendor_perl/5.8.8/POE/ at 1404) 5 -> set_port (from ./ at 37) a 'POE::Component::Client::HTTP::Request=ARRAY(0x1640260)' event was sent from /usr/lib64/perl5/vendor_perl/5.8.8/POE/Component/Client/ at 230 to session 2 (UA) but session 2 (UA) has neither a handler for it nor one for _default Which proove that POE::Component::Client::HTTP::Request instance is used as event name, it converted to string, but since no event with 'POE::Component::Client::HTTP::Request=ARRAY(0x1640260)' name it just discarded.
text/x-perl 1.3k
#! /usr/bin/perl use strict; use warnings; sub POE::Kernel::ASSERT_DEFAULT () { 1 } use POE qw(Component::Server::TCP Component::Client::HTTP Filter::HTTPD); use HTTP::Request::Common qw(GET); use Socket; POE::Component::Client::HTTP->spawn(Alias => 'UA', FollowRedirects => 7); POE::Session->create ( inline_states => { _start => sub { $_[KERNEL]->alias_set('main') }, set_port => sub { $_[KERNEL]->post(UA => request => response => GET "$_[ARG0]/") }, response => sub { print $_[ARG1]->[0]->as_string, $_[KERNEL]->post(webserver => 'shutdown') } }, options => { trace => 1} ); POE::Component::Server::TCP->new ( Alias => 'webserver', Address => '', Port => 0, ClientInput => \&handle_request, ClientFlushed => sub { $_[HEAP]->{client}->shutdown_output }, ClientFilter => 'POE::Filter::HTTPD', Started => sub { my ($kernel, $heap) = @_[KERNEL, HEAP]; my $port = (sockaddr_in($heap->{listener}->getsockname))[0]; $kernel->post('main', 'set_port', $port); } ); POE::Kernel->run; sub handle_request { my ($kernel, $heap, $request) = @_[KERNEL, HEAP, ARG0]; if ($request->isa("HTTP::Response")) { $heap->{client}->put($request); $kernel->yield("shutdown"); return; } $heap->{client}->put(HTTP::Response->new(302, 'Found', [Location => 'http:///'])); }
Thank you again for the test case and patch. Applied as revisioin 321. :)

This service is sponsored and maintained by Best Practical Solutions and runs on infrastructure.

Please report any issues with to