Skip Menu |

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

Report information
The Basics
Id: 30282
Status: resolved
Priority: 0/
Queue: POE-Component-FastCGI

People
Owner: Nobody in particular
Requestors: bra [...] fsn.hu
Cc:
AdminCc:

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



Subject: POE callbacks?
I am sure that the author has made POE::Component::FastCGI as is, but I thought that callbacks should also be POE events and not directly called subroutines. So here's a quick and ugly patch, which hopefully lets the user choose between the two. Using POE callbacks is achieved by defining string handlers (not coderefs), and a Session must be given into which it should be posted).
Subject: pocofcgi.diff
.pm.orig Fri Oct 26 12:06:23 2007 +++ FastCGI.pm Fri Oct 26 13:48:29 2007 @@ -4,6 +4,8 @@ =head1 SYNOPSIS +You can use this module with a direct subroutine callback: + use POE; use POE::Component::FastCGI; @@ -23,6 +25,28 @@ $response->send; } +and a POE event callback: + + use POE; + use POE::Component::FastCGI; + + POE::Component::FastCGI->new( + Port => 1026, + Handlers => [ + [ '/' => 'poe_event_name' ], + ] + Session => 'MAIN', + ); + + sub default { + my($request) = @_; + + my $response = $request->make_response; + $response->header("Content-type" => "text/html"); + $response->content("A page"); + $response->send; + } + =head1 DESCRIPTION Provides a FastCGI (L<http://www.fastcgi.com/>) server for L<POE>. @@ -56,13 +80,15 @@ Auth (optional) A code reference to run when called as a FastCGI authorizer. Handlers (required) - A array reference with a mapping of paths to code references. + A array reference with a mapping of paths to code references or POE event names. Port (required unless Unix is set) Port number to listen on. Address (requied if Unix is set) Address to listen on. Unix (optional) Listen on UNIX socket given in Address. + Session (required if you want to get POE callbacks) + Into which session we should post the POE event back. The handlers parameter should be a list of lists defining either regexps of paths to match or absolute paths to code references. @@ -138,7 +164,7 @@ } sub _input { - my($heap, $fcgi, $wheel_id) = @_[HEAP, ARG0, ARG1]; + my($heap, $kernel, $fcgi, $wheel_id) = @_[HEAP, KERNEL, ARG0, ARG1]; my $client = $heap->{wheels}->{$wheel_id}; @@ -175,7 +201,11 @@ if(not defined $run) { $request->error(404, "No handler found for $path"); }else{ - $run->[1]->($request, $run->[0]); + if(ref($run->[1]) eq 'CODE') { + $run->[1]->($request, $run->[0]); + } else { + $_[KERNEL]->post($heap->{Session}, $run->[1],$request, $run->[0]); + } } }
Sorry, I didn't see this bug report for some reason. This module is no longer maintained, I have applied your patch and made one last release to CPAN.