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

NAME

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

VERSION

9       version 1.2
10

SYNOPSIS

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

DESCRIPTION

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

METHODS

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

SEE ALSO

81       examples directory in this distribution.
82       WWW::Mechanize::CGI
83       Test::WWW::Mechanize::CGI
84

THANKS TO

86       Thomas L. Shinnick for his valuable win32 testing.
87

AUTHORS

89       Christian Hansen <ch@ngmedia.com> Hans Dieter Pearcey <hdp@cpan.org>
90
92       This software is copyright (c) 2010 by Christian Hansen
93       <ch@ngmedia.com>.
94
95       This is free software; you can redistribute it and/or modify it under
96       the same terms as the Perl 5 programming language system itself.
97
98
99
100perl v5.38.0                      2023-07-20           HTTP::Request::AsCGI(3)
Impressum