| FCGI::Async - Module to allow use of FastCGI asynchronously |
FCGI::Async - Module to allow use of FastCGI asynchronously
NOTE: The constructor API of this module has changed since version 0.13!
This module allows a program to respond to FastCGI requests using an asynchronous model. It is based on the IO::Async manpage and will fully interact with any program using this base.
use FCGI::Async; use IO::Async::Loop;
my $loop = IO::Async::Loop->new();
my $fcgi = FCGI::Async->new(
loop => $loop,
service => 1234,
on_request => sub {
my ( $fcgi, $req ) = @_;
# Handle the request here
}
);
$loop->loop_forever;
Or
my $fcgi = FCGI::Async->new( on_request => ... );
my $loop = ...
$loop->add( $fcgi );
$fcgi->listen( service => 1234 );
This function returns a new instance of a FCGI::Async object.
The %args hash must contain the following:
Reference to a handler to call when a new FastCGI request is received. It will be invoked as
$on_request->( $fcgi, $request )
where $request will be a new the FCGI::Async::Request manpage object.
If either a handle or service argument are passed to the constructor,
then the newly-created object is added to the given IO::Async::Loop, then
the listen method is invoked, passing the entire %args hash to it. For
more detail, see the listen method below.
If of the above arguments are given, then a IO::Async::Loop must also be
provided:
A reference to the IO::Async::Loop which will contain the listening
sockets.
Start listening for connections on a socket, creating it first if necessary.
This method may be called in either of the following ways. To listen on an existing socket filehandle:
An IO handle referring to a listen-mode socket.
Or, to create the listening socket or sockets:
Port number or service name to listen on.
Optional. If supplied, the hostname will be resolved into a set of addresses, and one listening socket will be created for each address. If not, then all available addresses will be used.
This method may also require on_listen_error or on_resolve_error
callbacks for error handling - see the IO::Async::Listener manpage for more detail.
When running a local FastCGI responder, the webserver will create a new INET socket connected to the script's STDIN file handle. To use the socket in this case, it should be passed as the 'socket'
the CGI::Fast manpage - Fast CGI drop-in replacement of CGI; single-threaded, blocking mode.
http://hoohoo.ncsa.uiuc.edu/cgi/interface.html - The Common Gateway Interface Specification
http://www.fastcgi.com/devkit/doc/fcgi-spec.html - FastCGI Specification
Paul Evans <leonerd@leonerd.org.uk>
| FCGI::Async - Module to allow use of FastCGI asynchronously |