1Mojo::Message::Request(U3s)er Contributed Perl DocumentatMioojno::Message::Request(3)
2
3
4
6 Mojo::Message::Request - HTTP 1.1 Request Container
7
9 use Mojo::Message::Request;
10
11 my $req = Mojo::Message::Request->new;
12 $req->url->parse('http://127.0.0.1/foo/bar');
13 $req->method('GET');
14
15 print "$req";
16
17 $req->parse('GET /foo/bar HTTP/1.1');
18
20 Mojo::Message::Request is a container for HTTP 1.1 requests as
21 described in RFC 2616.
22
24 Mojo::Message::Request inherits all attributes from Mojo::Message and
25 implements the following new ones.
26
27 "env"
28 my $env = $req->env;
29 $req = $req->env({});
30
31 Direct access to the environment hash if available.
32
33 "method"
34 my $method = $req->method;
35 $req = $req->method('GET');
36
37 HTTP request method.
38
39 "params"
40 my $params = $req->params;
41
42 All "GET" and "POST" parameters, defaults to a Mojo::Parameters object.
43
44 "query_params"
45 my $params = $req->query_params;
46
47 All "GET" parameters, defaults to a Mojo::Parameters object.
48
49 "url"
50 my $url = $req->url;
51 $req = $req->url(Mojo::URL->new);
52
53 HTTP request URL, defaults to a Mojo::URL object.
54
56 Mojo::Message::Request inherits all methods from Mojo::Message and
57 implements the following new ones.
58
59 "cookies"
60 my $cookies = $req->cookies;
61 $req = $req->cookies(Mojo::Cookie::Request->new);
62 $req = $req->cookies({name => 'foo', value => 'bar'});
63
64 Access request cookies.
65
66 "fix_headers"
67 $req = $req->fix_headers;
68
69 Make sure message has all required headers for the current HTTP
70 version.
71
72 "is_secure"
73 my $secure = $req->is_secure;
74
75 Check if connection is secure.
76
77 "is_xhr"
78 my $xhr = $req->is_xhr;
79
80 Check "X-Requested-With" header for "XMLHttpRequest" value.
81
82 "param"
83 my $param = $req->param('foo');
84
85 Access "GET" and "POST" parameters, defaults to a Mojo::Parameters
86 object.
87
88 "parse"
89 $req = $req->parse('GET /foo/bar HTTP/1.1');
90 $req = $req->parse(REQUEST_METHOD => 'GET');
91 $req = $req->parse({REQUEST_METHOD => 'GET'});
92
93 Parse HTTP request chunks or environment hash.
94
95 "proxy"
96 my $proxy = $req->proxy;
97 $req = $req->proxy('http://foo:bar@127.0.0.1:3000');
98 $req = $req->proxy(Mojo::URL->new('http://127.0.0.1:3000'));
99
100 Proxy URL for message.
101
103 Mojolicious, Mojolicious::Guides, <http://mojolicious.org>.
104
105
106
107perl v5.12.3 2010-08-12 Mojo::Message::Request(3)