1Catalyst::Response(3) User Contributed Perl DocumentationCatalyst::Response(3)
2
3
4

NAME

6       Catalyst::Response - stores output responding to the current client
7       request
8

SYNOPSIS

10           $res = $c->response;
11           $res->body;
12           $res->code;
13           $res->content_encoding;
14           $res->content_length;
15           $res->content_type;
16           $res->cookies;
17           $res->header;
18           $res->headers;
19           $res->output;
20           $res->redirect;
21           $res->status;
22           $res->write;
23

DESCRIPTION

25       This is the Catalyst Response class, which provides methods for
26       responding to the current client request. The appropriate
27       Catalyst::Engine for your environment will turn the Catalyst::Response
28       into a HTTP Response and return it to the client.
29

METHODS

31   $res->body( $text | $fh | $iohandle_object )
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::Handle 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->has_body
41       Predicate which returns true when a body has been set.
42
43   $res->code
44       Alias for $res->status.
45
46   $res->content_encoding
47       Shortcut for $res->headers->content_encoding.
48
49   $res->content_length
50       Shortcut for $res->headers->content_length.
51
52   $res->content_type
53       Shortcut for $res->headers->content_type.
54
55       This value is typically set by your view or plugin. For example,
56       Catalyst::Plugin::Static::Simple will guess the mime type based on the
57       file it found, while Catalyst::View::TT defaults to "text/html".
58
59   $res->cookies
60       Returns a reference to a hash containing cookies to be set. The keys of
61       the hash are the cookies' names, and their corresponding values are
62       hash references used to construct a CGI::Simple::Cookie object.
63
64           $c->response->cookies->{foo} = { value => '123' };
65
66       The keys of the hash reference on the right correspond to the
67       CGI::Simple::Cookie parameters of the same name, except they are used
68       without a leading dash.  Possible parameters are:
69
70       value
71       expires
72       domain
73       path
74       secure
75       httponly
76
77   $res->header
78       Shortcut for $res->headers->header.
79
80   $res->headers
81       Returns an HTTP::Headers object, which can be used to set headers.
82
83           $c->response->headers->header( 'X-Catalyst' => $Catalyst::VERSION );
84
85   $res->output
86       Alias for $res->body.
87
88   $res->redirect( $url, $status )
89       Causes the response to redirect to the specified URL. The default
90       status is 302.
91
92           $c->response->redirect( 'http://slashdot.org' );
93           $c->response->redirect( 'http://slashdot.org', 307 );
94
95       This is a convenience method that sets the Location header to the
96       redirect destination, and then sets the response status.  You will want
97       to " return " or "$c->detach()" to interrupt the normal processing flow
98       if you want the redirect to occur straight away.
99
100   $res->location
101       Sets or returns the HTTP 'Location'.
102
103   $res->status
104       Sets or returns the HTTP status.
105
106           $c->response->status(404);
107
108       $res->code is an alias for this, to match HTTP::Response->code.
109
110   $res->write( $data )
111       Writes $data to the output stream.
112
113   meta
114       Provided by Moose
115
116   $res->print( @data )
117       Prints @data to the output stream, separated by $,.  This lets you pass
118       the response object to functions that want to write to an IO::Handle.
119

AUTHORS

121       Catalyst Contributors, see Catalyst.pm
122
124       This library is free software. You can redistribute it and/or modify it
125       under the same terms as Perl itself.
126
127
128
129perl v5.12.1                      2009-11-24             Catalyst::Response(3)
Impressum