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 of HTTP::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 in setup. heads up though: if you mess with that hashref after setup has 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 after setup. 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 a HTTP::Response. can only be called after restore, so don't get ahead of yourself. ⭐
  • stdin β€” accessor for the handle that'll be used for STDIN. it must be a real seekable handle with a file descriptor. defaults to a temporary IO::File instance. πŸ’–
  • stdout β€” accessor for the handle that'll be used for STDOUT. same deal: it must be a real seekable handle with a file descriptor. defaults to a temporary IO::File instance. πŸ’–
  • stderr β€” accessor for the handle that'll be used for STDERR. 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 examples directory in this distribution. go look, it's right there.
  • WWW::Mechanize::CGI
  • Test::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. πŸ‘‘


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