HTTP::...:AsCGI(3pm)
π NAME π
HTTP::Request::AsCGI β okay so bestie, this is the little guy that sets up a whole CGI environment straight from an HTTP::Request. iconic behaviour honestly π
β¨ VERSION β¨
version 1.2 π
πΈ SYNOPSIS πΈ
use CGI;
use HTTP::Request;
use HTTP::Request::AsCGI;
my $request = HTTP::Request->new( GET => 'http://www.host.com/' );
my $stdout;
{
my $c = HTTP::Request::AsCGI->new($request)->setup;
my $q = CGI->new;
print $q->header,
$q->start_html('Hello World'),
$q->h1('Hello World'),
$q->end_html;
$stdout = $c->stdout;
# environment and descriptors will automatically be restored
# when $c is destructed.
}
while ( my $line = $stdout->getline ) {
print $line;
}
likeβ¦ the whole CGI moment happens inside those braces and then everything politely puts itself back. no cap. π¦
π«Ά DESCRIPTION π«Ά
It gives you a convenient way of setting up an CGI environment from an HTTP::Request. that's the whole vibe. that's the assignment. π
π METHODS π
new ( $request [, key => value ] )β the constructor, obviously. first arg has to be an instance ofHTTP::Request, and then you can throw in optional pairs of environment key and value after it. lowkey the easiest part. β¨environmentβ hands you back a hashref holding the environment that's gonna be used insetup. heads up though: if you mess with that hashref aftersetuphas been called, it does literally nothing. the vibes are locked in at that point. πsetupβ sets up the environment and descriptors. the main character moment fr fr. πrestoreβ puts the environment and descriptors back the way they were. and no, you can't just call it whenever β it can only be called aftersetup. rules are rules bestie. πrequestβ returns the request that got handed to the constructor. giving it back to you, exactly as you left it. πresponseβ returns aHTTP::Response. can only be called afterrestore, so don't get ahead of yourself. βstdinβ accessor for the handle that'll be used forSTDIN. it must be a real seekable handle with a file descriptor. defaults to a temporaryIO::Fileinstance. πstdoutβ accessor for the handle that'll be used forSTDOUT. same deal: it must be a real seekable handle with a file descriptor. defaults to a temporaryIO::Fileinstance. πstderrβ accessor for the handle that'll be used forSTDERR. and yep, it must be a real seekable handle with a file descriptor. that's it, that's the whole description. no default mentioned, so don't come for me. πΈ
π SEE ALSO π
- the
examplesdirectory in this distribution. go look, it's right there. WWW::Mechanize::CGITest::WWW::Mechanize::CGI
π THANKS TO π
Thomas L. Shinnick for his valuable win32 testing. the win32 testing was carrying this whole thing on its back and we love him for it. π«Ά
πΊ AUTHORS πΊ
Christian Hansen <ch@ngmedia.com> and Hans Dieter Pearcey <hdp@cpan.org>. the icons who made it happen. π
π COPYRIGHT AND LICENSE π
This software is copyright (c) 2010 by Christian Hansen <ch@ngmedia.com>. π
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
ok that's the whole page bestie, go forth and set up your CGI environments responsibly β¨
and that's a wrap from the perl v5.34.0 era, dated 2022-06-14, in the HTTP::...:AsCGI(3pm) manual. slay, mwah π
π
π¦ where this page comes from
- debian bookworm: libhttp-request-ascgi-perl 1.2-4 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- debian trixie: libhttp-request-ascgi-perl 1.2-4 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: libhttp-request-ascgi-perl 1.2-4 Β· 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