1Mojo::Message::ResponseU(s3e)r Contributed Perl DocumentaMtoijoon::Message::Response(3)
2
3
4
6 Mojo::Message::Response - HTTP 1.1 Response Container
7
9 use Mojo::Message::Response;
10
11 my $res = Mojo::Message::Response->new;
12 $res->code(200);
13 $res->headers->content_type('text/plain');
14 $res->body('Hello World!');
15
16 print "$res";
17
18 $res->parse('HTTP/1.1 200 OK');
19
21 Mojo::Message::Response is a container for HTTP 1.1 responses as
22 described in RFC 2616.
23
25 Mojo::Message::Response inherits all attributes from Mojo::Message and
26 implements the following new ones.
27
28 "code"
29 my $code = $res->code;
30 $res = $res->code(200);
31
32 HTTP response code.
33
34 "message"
35 my $message = $res->message;
36 $res = $res->message('OK');
37
38 HTTP response message.
39
41 Mojo::Message::Response inherits all methods from Mojo::Message and
42 implements the following new ones.
43
44 "cookies"
45 my $cookies = $res->cookies;
46 $res = $res->cookies(Mojo::Cookie::Response->new);
47 $req = $req->cookies({name => 'foo', value => 'bar'});
48
49 Access response cookies.
50
51 "default_message"
52 my $message = $res->default_message;
53
54 Generate default response message for code.
55
56 "fix_headers"
57 $res = $res->fix_headers;
58
59 Make sure message has all required headers for the current HTTP
60 version.
61
62 "is_status_class"
63 my $is_2xx = $res->is_status_class(200);
64
65 Check response status class.
66
67 "parse"
68 $res = $res->parse('HTTP/1.1 200 OK');
69
70 Parse HTTP response chunk.
71
72 "parse_until_body"
73 $res = $res->parse_until_body('HTTP/1.1 200 OK');
74
75 Parse HTTP response chunk until the body is reached.
76
78 Mojolicious, Mojolicious::Guides, <http://mojolicious.org>.
79
80
81
82perl v5.12.3 2010-08-12 Mojo::Message::Response(3)