AnyEve...Request(3pm)
π AnyEve...Request(3pm) β User Contributed Perl Documentation π
okay bestie, welcome to the manual page for AnyEvent::FCGI::Request β she's the single FastCGI request handle for AnyEvent::FCGI, and she's iconic, no cap. this is your group chat crash course, let's go π«Ά
β¨ 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;
like, that's the whole vibe right there β¨
π¦ DESCRIPTION π¦
so this is the request object that AnyEvent::FCGI generates for you. the way that works is: when it gets handed to your controlling program, every request already has its parameters and its STDIN data all ready to go. your program can then write response data to the STDOUT stream, write messages to the STDERR stream, and eventually finish the request off. it's giving very organized, very main character π
lowkey important though: your program would not use this module directly if it's using AnyEvent::FCGI. instead, objects of this class get passed into the on_request callback of the containing AnyEvent::FCGI object. iykyk π
π METHODS π
is_active
returns false if the webserver has already closed the control connection. if that's happened, no further work on this request is necessary β she's getting discarded, bye π
you'd use this method if the response is not going to be sent immediately from the on_request callback.
param($key)
this method returns the value of a single request parameter. if no such key exists, you get undef back instead. simple as that bestie π
params
this method returns a reference to a hash containing a copy of the request parameters that the webserver sent as part of the request. a copy, okay? not a live link. respect the boundary β¨
read_stdin($size)
this one works similarly to the read(HANDLE) function. it returns the next block of up to $size bytes from the STDIN buffer. if there's no data available any more, then undef is returned instead. snack-sized chunks of input π
print_stdout($data)
this method appends the given data to the STDOUT stream of the FastCGI request β sending it to the webserver so it can be sent to the client. it's the pipeline, babe π
print_stderr($data)
this method appends the given data to the STDERR stream of the FastCGI request, sending it to the webserver. that's the other stream, for the stuff that isn't the response. keep them separate π
finish
when the request has been dealt with, this method should be called, because it indicates to the webserver that it is finished. periodt π
β οΈ after calling this method, no more data may be appended to the STDOUT stream. like, at all. she's closed. don't try it.
respond($content, @headers)
this method sends the response to the webserver and finishes the request β a two-for-one, obsessed ππ
the HTTP reply code can be specified in the Status header (200 by default, naturally).
this method can be used instead of print_stdout and finish, so it's the shortcut girlies will reach for ββ¨
and that's the whole page, bestie π
source/version: perl v5.36.0 Β· date: 2022-10-14
mwah, go write some slay FastCGI handlers, you've got this ππ π¦
π¦ where this page comes from
- ubuntu noble: libanyevent-fcgi-perl 0.04-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libanyevent-fcgi-perl 0.04-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libanyevent-fcgi-perl 0.04-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms