-
-
04 May 2011 13:09:20 UTC
- Distribution: AnyEvent-FCGI
- Source (raw)
- Browse (raw)
- Changes
- How to Contribute
- Issues (2)
- Testers (992 / 0 / 0)
- Kwalitee
Bus factor: 0- 87.50% Coverage
- License: unknown
- Activity
24 month- Tools
- Download (5.11KB)
- MetaCPAN Explorer
- Permissions
- Subscribe to distribution
- Permalinks
- This version
- Latest version
++ed by:1 non-PAUSE user- Dependencies
- unknown
- Reverse dependencies
- CPAN Testers List
- Dependency graph
NAME
AnyEvent::FCGI::Request - a single FastCGI request handle for AnyEvent::FCGI
SYNOPSIS
use AnyEvent; use AnyEvent::FCGI; use CGI::Stateless; my $fcgi = new AnyEvent::FCGI( port => 9000, on_request => sub { my $request = shift; local *STDIN; open STDIN, '<', \$request->read_stdin; local %ENV = %{$request->params}; local $CGI::Q = new CGI::Stateless; $request->respond( 'Hello, ' . (CGI::param('name') || 'anonymous'), 'Content-Type' => 'text/html; charset=utf8', 'Set-Cookie' => 'cookie_a=1; path=/', 'Set-Cookie' => 'cookie_b=2; path=/', ); } ); AnyEvent->loop;
DESCRIPTION
This is the request object as generated by AnyEvent::FCGI. When given to the controlling program, each request will already have its parameters and STDIN data. The program can then write response data to the STDOUT stream, messages to the STDERR stream, and eventually finish it.
This module would not be used directly by a program using
AnyEvent::FCGI
, but rather, objects in this class are passed into theon_request
callback of the containingAnyEvent::FCGI
object.METHODS
is_active
Returns false if the webserver has already closed the control connection. No further work on this request is necessary, as it will be discarded.
This method can be used if response will not be sent immediately from
on_request
callback.param($key)
This method returns the value of a single request parameter, or
undef
if no such key exists.params
This method returns a reference to a hash containing a copy of the request parameters that had been sent by the webserver as part of the request.
read_stdin($size)
This method works similarly to the
read(HANDLE)
function. It returns the next block of up to $size bytes from the STDIN buffer. If no data is available any more, thenundef
is returned instead.print_stdout($data)
This method appends the given data to the STDOUT stream of the FastCGI request, sending it to the webserver to be sent to the client.
print_stderr($data)
This method appends the given data to the STDERR stream of the FastCGI request, sending it to the webserver.
finish
When the request has been dealt with, this method should be called to indicate to the webserver that it is finished. After calling this method, no more data may be appended to the STDOUT stream.
respond($content, @headers)
This method sends the response to the webserver and finishes the request. HTTP reply code can be specified in
Status
header (200 by default). This method can be used instead ofprint_stdout
andfinish
.Module Install Instructions
To install AnyEvent::FCGI, copy and paste the appropriate command in to your terminal.
cpanm AnyEvent::FCGI
perl -MCPAN -e shell install AnyEvent::FCGI
For more information on module installation, please visit the detailed CPAN module installation guide.