~ubuntu-branches/ubuntu/quantal/libhttp-request-ascgi-perl/quantal

« back to all changes in this revision

Viewing changes to README

  • Committer: Bazaar Package Importer
  • Author(s): Krzysztof Krzyzaniak (eloy)
  • Date: 2005-11-16 13:59:02 UTC
  • Revision ID: james.westby@ubuntu.com-20051116135902-mczwe8n9t4ynigrj
Tags: upstream-0.2
ImportĀ upstreamĀ versionĀ 0.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
NAME
 
2
    HTTP::Request::AsCGI - Setup a CGI enviroment from a HTTP::Request
 
3
 
 
4
SYNOPSIS
 
5
        use CGI;
 
6
        use HTTP::Request;
 
7
        use HTTP::Request::AsCGI;
 
8
    
 
9
        my $request = HTTP::Request->new( GET => 'http://www.host.com/' );
 
10
        my $stdout;
 
11
    
 
12
        {
 
13
            my $c = HTTP::Request::AsCGI->new($request)->setup;
 
14
            my $q = CGI->new;
 
15
        
 
16
            print $q->header,
 
17
                  $q->start_html('Hello World'),
 
18
                  $q->h1('Hello World'),
 
19
                  $q->end_html;
 
20
        
 
21
            $stdout = $c->stdout;
 
22
        
 
23
            # enviroment and descriptors will automatically be restored 
 
24
            # when $c is destructed.
 
25
        }
 
26
    
 
27
        while ( my $line = $stdout->getline ) {
 
28
            print $line;
 
29
        }
 
30
    
 
31
DESCRIPTION
 
32
    Provides a convinient way of setting up an CGI enviroment from a
 
33
    HTTP::Request.
 
34
 
 
35
METHODS
 
36
    new ( $request [, key => value ] )
 
37
        Contructor, first argument must be a instance of HTTP::Request
 
38
        followed by optional pairs of environment key and value.
 
39
 
 
40
    enviroment
 
41
        Returns a hashref containing the environment that will be used in
 
42
        setup. Changing the hashref after setup has been called will have no
 
43
        effect.
 
44
 
 
45
    setup
 
46
        Setups the environment and descriptors.
 
47
 
 
48
    restore
 
49
        Restores the enviroment and descriptors. Can only be called after
 
50
        setup.
 
51
 
 
52
    request
 
53
        Returns the request given to constructor.
 
54
 
 
55
    response
 
56
        Returns a HTTP::Response. Can only be called after restore.
 
57
 
 
58
    stdin
 
59
        Accessor for handle that will be used for STDIN, must be a real
 
60
        seekable handle with an file descriptor. Defaults to a tempoary
 
61
        IO::File instance.
 
62
 
 
63
    stdout
 
64
        Accessor for handle that will be used for STDOUT, must be a real
 
65
        seekable handle with an file descriptor. Defaults to a tempoary
 
66
        IO::File instance.
 
67
 
 
68
    stderr
 
69
        Accessor for handle that will be used for STDERR, must be a real
 
70
        seekable handle with an file descriptor.
 
71
 
 
72
SEE ALSO
 
73
    examples directory in this distribution.
 
74
    WWW::Mechanize::CGI
 
75
    Test::WWW::Mechanize::CGI
 
76
 
 
77
THANKS TO
 
78
    Thomas L. Shinnick for his valuable win32 testing.
 
79
 
 
80
AUTHOR
 
81
    Christian Hansen, "ch@ngmedia.com"
 
82
 
 
83
LICENSE
 
84
    This library is free software. You can redistribute it and/or modify it
 
85
    under the same terms as perl itself.
 
86