1HTTP::Request::AsCGI(3)User Contributed Perl DocumentatioHnTTP::Request::AsCGI(3)
2
3
4

NAME

6       HTTP::Request::AsCGI - Setup a CGI enviroment from a HTTP::Request
7

SYNOPSIS

9           use CGI;
10           use HTTP::Request;
11           use HTTP::Request::AsCGI;
12
13           my $request = HTTP::Request->new( GET => 'http://www.host.com/' );
14           my $stdout;
15
16           {
17               my $c = HTTP::Request::AsCGI->new($request)->setup;
18               my $q = CGI->new;
19
20               print $q->header,
21                     $q->start_html('Hello World'),
22                     $q->h1('Hello World'),
23                     $q->end_html;
24
25               $stdout = $c->stdout;
26
27               # enviroment and descriptors will automatically be restored
28               # when $c is destructed.
29           }
30
31           while ( my $line = $stdout->getline ) {
32               print $line;
33           }
34

DESCRIPTION

36       Provides a convinient way of setting up an CGI enviroment from a
37       HTTP::Request.
38

METHODS

40       new ( $request [, key => value ] )
41           Contructor, first argument must be a instance of HTTP::Request fol‐
42           lowed by optional pairs of environment key and value.
43
44       enviroment
45           Returns a hashref containing the environment that will be used in
46           setup.  Changing the hashref after setup has been called will have
47           no effect.
48
49       setup
50           Setups the environment and descriptors.
51
52       restore
53           Restores the enviroment and descriptors. Can only be called after
54           setup.
55
56       request
57           Returns the request given to constructor.
58
59       response
60           Returns a HTTP::Response. Can only be called after restore.
61
62       stdin
63           Accessor for handle that will be used for STDIN, must be a real
64           seekable handle with an file descriptor. Defaults to a tempoary
65           IO::File instance.
66
67       stdout
68           Accessor for handle that will be used for STDOUT, must be a real
69           seekable handle with an file descriptor. Defaults to a tempoary
70           IO::File instance.
71
72       stderr
73           Accessor for handle that will be used for STDERR, must be a real
74           seekable handle with an file descriptor.
75

SEE ALSO

77       examples directory in this distribution.
78       WWW::Mechanize::CGI
79       Test::WWW::Mechanize::CGI
80

THANKS TO

82       Thomas L. Shinnick for his valuable win32 testing.
83

AUTHOR

85       Christian Hansen, "ch@ngmedia.com"
86

LICENSE

88       This library is free software. You can redistribute it and/or modify it
89       under the same terms as perl itself.
90
91
92
93perl v5.8.8                       2006-01-20           HTTP::Request::AsCGI(3)
Impressum