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, consist‐
19       ing of a request line, some headers, and a content body. Note that the
20       LWP library uses HTTP style requests even for non-HTTP protocols.
21       Instances of this class are usually passed to the request() method of
22       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 ref‐
34           erence to an "HTTP::Headers" object or a plain array reference of
35           key/value pairs.  The optional $content argument should be a string
36           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 ref‐
49           erence 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->content
59       $r->content( $content )
60           This is used to get/set the content and it is inherited from the
61           "HTTP::Message" base class.  See HTTP::Message for details and
62           other methods that can be used to access the content.
63
64           Note that the content should be a string of bytes.  Strings in perl
65           can contain characters outside the range of a byte.  The "Encode"
66           module can be used to turn such strings into a string of bytes.
67
68       $r->as_string
69       $r->as_string( $eol )
70           Method returning a textual representation of the request.
71

SEE ALSO

73       HTTP::Headers, HTTP::Message, HTTP::Request::Common, HTTP::Response
74
76       Copyright 1995-2004 Gisle Aas.
77
78       This library is free software; you can redistribute it and/or modify it
79       under the same terms as Perl itself.
80
81
82
83perl v5.8.8                       2004-04-06                  HTTP::Request(3)
Impressum