CGI::Parse::PSGI(3pm)
β¨ NAME β¨
CGI::Parse::PSGI β bestie, this thing parses CGI output and creates a PSGI response out of it π like it literally takes the messy lil text blob your CGI script spat out and turns it into a whole PSGI glow-up.
πΈ DESCRIPTION πΈ
okay so first things first, here's the vibe:
use CGI::Parse::PSGI qw(parse_cgi_output);
my $output = YourApp->run;
my $psgi_res = parse_cgi_output(\$output);
see? you run your app, you get $output, you hand it over, and boom π
you get a PSGI response back.
and guess what, you can also pass an option hash if you're feeling fancy:
my $psgi_res = parse_cgi_output(\$output, \%options);
iconic. moving on π¦
β SYNOPSIS β
CGI::Parse::PSGI exports exactly one function, parse_cgi_output, and she's the main character π. She takes a filehandle or a reference to a string, reads a CGI script output from it, and creates a PSGI response (that's an array reference containing the status code, the headers, and a body, no cap) by reading the output.
now, if what you've got is actual CGI code and not the output, then bestie you want CGI::Emulate::PSGI instead β that one takes care of automatically parsing the output, using this module, straight from your callback code. teamwork makes the dream work fr fr π«Ά
π OPTIONS π
like we said up there, parse_cgi_output can accept an options hash as the second argument. here's what's on the menu rn:
ignore_status_lineβ a boolean value, defaulting to0(false). if it's true, then the status in the HTTP protocol line is not used to set the default status when there's no status header present. lowkey niche but highkey useful, iykyk.
and here's the cute part: you can supply these options to earlier versions too, and they'll just be ignored without error. no drama, no crash, just vibes. so you can preserve legacy behaviour like this:
parse_cgi_output(\$output, {ignore_status_line => 1});
this will ensure that if the script output includes an edge case like this:
HTTP/1.1 666 SNAFU
Content-Type: text/plain
This should be OK!
then the old behaviour of ignoring the status line and returning 200 is preserved β¨ periodt. no 666 jumpscare for you, bestie.
π AUTHOR π
Tatsuhiko Miyagawa β the icon, the legend π«‘
π SEE ALSO π
CGI::Emulate::PSGI
and that's the whole page, babe π this manual came from perl v5.34.0, dated 2022-06-09, and it's the CGI::Parse::PSGI(3pm) page from your friendly neighbourhood User Contributed Perl Documentation. go parse something cute β¨π¦π
π¦ where this page comes from
- debian bookworm: libcgi-emulate-psgi-perl 0.23-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- debian trixie: libcgi-emulate-psgi-perl 0.23-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: libcgi-emulate-psgi-perl 0.23-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libcgi-emulate-psgi-perl 0.23-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libcgi-emulate-psgi-perl 0.23-2 Β· 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