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

NAME

6       HTTP::Request - HTTP style request message
7

SYNOPSIS

9        require HTTP::Request;
10        $request = HTTP::Request->new(GET => 'http://www.example.com/');
11
12       and usually used like this:
13
14        $ua = LWP::UserAgent->new;
15        $response = $ua->request($request);
16

DESCRIPTION

18       "HTTP::Request" is a class encapsulating HTTP style requests,
19       consisting of a request line, some headers, and a content body. Note
20       that the LWP library uses HTTP style requests even for non-HTTP
21       protocols.  Instances of this class are usually passed to the request()
22       method of an "LWP::UserAgent" object.
23
24       "HTTP::Request" is a subclass of "HTTP::Message" and therefore inherits
25       its methods.  The following additional methods are available:
26
27       $r = HTTP::Request->new( $method, $uri )
28       $r = HTTP::Request->new( $method, $uri, $header )
29       $r = HTTP::Request->new( $method, $uri, $header, $content )
30           Constructs a new "HTTP::Request" object describing a request on the
31           object $uri using method $method.  The $method argument must be a
32           string.  The $uri argument can be either a string, or a reference
33           to a "URI" object.  The optional $header argument should be a
34           reference to an "HTTP::Headers" object or a plain array reference
35           of key/value pairs.  The optional $content argument should be a
36           string of bytes.
37
38       $r = HTTP::Request->parse( $str )
39           This constructs a new request object by parsing the given string.
40
41       $r->method
42       $r->method( $val )
43           This is used to get/set the method attribute.  The method should be
44           a short string like "GET", "HEAD", "PUT" or "POST".
45
46       $r->uri
47       $r->uri( $val )
48           This is used to get/set the uri attribute.  The $val can be a
49           reference to a URI object or a plain string.  If a string is given,
50           then it should be parseable as an absolute URI.
51
52       $r->header( $field )
53       $r->header( $field => $value )
54           This is used to get/set header values and it is inherited from
55           "HTTP::Headers" via "HTTP::Message".  See HTTP::Headers for details
56           and other similar methods that can be used to access the headers.
57
58       $r->accept_decodable
59           This will set the "Accept-Encoding" header to the list of encodings
60           that decoded_content() can decode.
61
62       $r->content
63       $r->content( $bytes )
64           This is used to get/set the content and it is inherited from the
65           "HTTP::Message" base class.  See HTTP::Message for details and
66           other methods that can be used to access the content.
67
68           Note that the content should be a string of bytes.  Strings in perl
69           can contain characters outside the range of a byte.  The "Encode"
70           module can be used to turn such strings into a string of bytes.
71
72       $r->as_string
73       $r->as_string( $eol )
74           Method returning a textual representation of the request.
75

SEE ALSO

77       HTTP::Headers, HTTP::Message, HTTP::Request::Common, HTTP::Response
78
80       Copyright 1995-2004 Gisle Aas.
81
82       This library is free software; you can redistribute it and/or modify it
83       under the same terms as Perl itself.
84
85
86
87perl v5.16.3                      2012-02-15                  HTTP::Request(3)
Impressum