HTTP::Request::AsCGI - Setup a CGI enviroment from a HTTP::Request
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; # enviroment and descriptors will automatically be restored # when $c is destructed. } while ( my $line = $stdout->getline ) { print $line; }
Provides a convinient way of setting up an CGI enviroment from a HTTP::Request.
Contructor, first argument must be a instance of HTTP::Request followed by optional pairs of environment key and value.
Returns a hashref containing the environment that will be used in setup. Changing the hashref after setup has been called will have no effect.
Setups the environment and descriptors.
Restores the enviroment and descriptors. Can only be called after setup.
Returns the request given to constructor.
Returns a HTTP::Response. Can only be called after restore.
Accessor for handle that will be used for STDIN, must be a real seekable handle with an file descriptor. Defaults to a tempoary IO::File instance.
Accessor for handle that will be used for STDOUT, must be a real seekable handle with an file descriptor. Defaults to a tempoary IO::File instance.
Accessor for handle that will be used for STDERR, must be a real seekable handle with an file descriptor.
Thomas L. Shinnick for his valuable win32 testing.
Christian Hansen, ch@ngmedia.com
ch@ngmedia.com
This library is free software. You can redistribute it and/or modify it under the same terms as perl itself.
To install HTTP::Request::AsCGI, copy and paste the appropriate command in to your terminal.
cpanm
cpanm HTTP::Request::AsCGI
CPAN shell
perl -MCPAN -e shell install HTTP::Request::AsCGI
For more information on module installation, please visit the detailed CPAN module installation guide.