AnyEvent-FCGI
view release on metacpan or search on metacpan
lib/AnyEvent/FCGI.pm view on Meta::CPAN
package AnyEvent::FCGI;
=head1 NAME
AnyEvent::FCGI - non-blocking FastCGI server
=head1 SYNOPSIS
use AnyEvent;
use AnyEvent::FCGI;
my $fcgi = new AnyEvent::FCGI(
port => 9000,
on_request => sub {
my $request = shift;
$request->respond(
'OH HAI! QUERY_STRING is ' . $request->param('QUERY_STRING'),
'Content-Type' => 'text/plain',
);
}
);
my $timer = AnyEvent->timer(
after => 10,
interval => 0,
cb => sub {
# shut down server after 10 seconds
$fcgi = undef;
}
);
AnyEvent->loop;
=head1 DESCRIPTION
This module implements non-blocking FastCGI server for event based applications.
=cut
use strict;
use warnings;
our $VERSION = '0.04';
use Scalar::Util qw/weaken refaddr/;
use AnyEvent;
use AnyEvent::Socket;
use AnyEvent::Handle;
use AnyEvent::FCGI::Connection;
use constant FCGI_VERSION_1 => 1;
use constant FCGI_BEGIN_REQUEST => 1;
use constant FCGI_ABORT_REQUEST => 2;
use constant FCGI_END_REQUEST => 3;
use constant FCGI_PARAMS => 4;
use constant FCGI_STDIN => 5;
use constant FCGI_STDOUT => 6;
use constant FCGI_STDERR => 7;
use constant FCGI_RESPONDER => 1;
use constant FCGI_KEEP_CONN => 1;
use constant FCGI_REQUEST_COMPLETE => 0;
use constant FCGI_OVERLOADED => 2;
use constant FCGI_UNKNOWN_ROLE => 3;
=head1 METHODS
=head2 new
This function creates a new FastCGI server and returns a new instance of a C<AnyEvent::FCGI> object.
To shut down the server just remove all references to this object.
=head3 PARAMETERS
=over 4
=item port => $port
The TCP port the FastCGI server will listen on.
( run in 0.833 second using v1.01-cache-2.11-cpan-0b5f733616e )