1Catalyst::Response(3) User Contributed Perl DocumentationCatalyst::Response(3)
2
3
4
6 Catalyst::Response - stores output responding to the current client
7 request
8
10 $res = $c->response;
11 $res->body;
12 $res->content_encoding;
13 $res->content_length;
14 $res->content_type;
15 $res->cookies;
16 $res->header;
17 $res->headers;
18 $res->output;
19 $res->redirect;
20 $res->status;
21 $res->write;
22
24 This is the Catalyst Response class, which provides methods for
25 responding to the current client request. The appropriate Cata‐
26 lyst::Engine for your environment will turn the Catalyst::Response into
27 a HTTP Response and return it to the client.
28
30 $res->body(<$text⎪$fh⎪$iofh_object)
31
32 $c->response->body('Catalyst rocks!');
33
34 Sets or returns the output (text or binary data). If you are returning
35 a large body, you might want to use a IO::FileHandle type of object
36 (Something that implements the read method in the same fashion), or a
37 filehandle GLOB. Catalyst will write it piece by piece into the
38 response.
39
40 $res->content_encoding
41
42 Shortcut for $res->headers->content_encoding.
43
44 $res->content_length
45
46 Shortcut for $res->headers->content_length.
47
48 $res->content_type
49
50 Shortcut for $res->headers->content_type.
51
52 This value is typically set by your view or plugin. For example, Cata‐
53 lyst::Plugin::Static::Simple will guess the mime type based on the file
54 it found, while Catalyst::View::TT defaults to "text/html".
55
56 $res->cookies
57
58 Returns a reference to a hash containing cookies to be set. The keys of
59 the hash are the cookies' names, and their corresponding values are
60 hash references used to construct a CGI::Cookie object.
61
62 $c->response->cookies->{foo} = { value => '123' };
63
64 The keys of the hash reference on the right correspond to the
65 CGI::Cookie parameters of the same name, except they are used without a
66 leading dash. Possible parameters are:
67
68 value
69 expires
70 domain
71 path
72 secure
73
74 $res->header
75
76 Shortcut for $res->headers->header.
77
78 $res->headers
79
80 Returns an HTTP::Headers object, which can be used to set headers.
81
82 $c->response->headers->header( 'X-Catalyst' => $Catalyst::VERSION );
83
84 $res->output
85
86 Alias for $res->body.
87
88 $res->redirect( $url, $status )
89
90 Causes the response to redirect to the specified URL.
91
92 $c->response->redirect( 'http://slashdot.org' );
93 $c->response->redirect( 'http://slashdot.org', 307 );
94
95 $res->status
96
97 Sets or returns the HTTP status.
98
99 $c->response->status(404);
100
101 $res->write( $data )
102
103 Writes $data to the output stream.
104
106 Sebastian Riedel, "sri@cpan.org"
107
108 Marcus Ramberg, "mramberg@cpan.org"
109
111 This program is free software, you can redistribute it and/or modify it
112 under the same terms as Perl itself.
113
114
115
116perl v5.8.8 2007-09-20 Catalyst::Response(3)