GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
HTTP::Request::AsCGI(3) User Contributed Perl Documentation HTTP::Request::AsCGI(3)

HTTP::Request::AsCGI - Set up a CGI environment from an HTTP::Request

version 1.2

    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;
    }

Provides a convenient way of setting up an CGI environment from an HTTP::Request.

new ( $request [, key => value ] )
Constructor. The first argument must be a instance of HTTP::Request, followed by optional pairs of environment key and value.
environment
Returns a hashref containing the environment that will be used in setup. Changing the hashref after setup has been called will have no effect.
setup
Sets up the environment and descriptors.
restore
Restores the environment and descriptors. Can only be called after setup.
request
Returns the request given to constructor.
response
Returns a HTTP::Response. Can only be called after restore.
stdin
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.
stdout
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.
stderr
Accessor for handle that will be used for STDERR, must be a real seekable handle with an file descriptor.

examples directory in this distribution.
WWW::Mechanize::CGI
Test::WWW::Mechanize::CGI

Thomas L. Shinnick for his valuable win32 testing.

Christian Hansen <ch@ngmedia.com> Hans Dieter Pearcey <hdp@cpan.org>

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.

2010-01-12 perl v5.32.1

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.