Commit | Line | Data |
fc7ec1d9 |
1 | package Catalyst::Response; |
2 | |
3 | use strict; |
4 | use base 'Class::Accessor::Fast'; |
5 | |
6 | __PACKAGE__->mk_accessors(qw/cookies headers output redirect status/); |
7 | |
f7e4e231 |
8 | sub content_encoding { shift->headers->content_encoding(@_) } |
9 | sub content_length { shift->headers->content_length(@_) } |
10 | sub content_type { shift->headers->content_type(@_) } |
11 | sub header { shift->headers->header(@_) } |
12 | |
fc7ec1d9 |
13 | =head1 NAME |
14 | |
15 | Catalyst::Response - Catalyst Response Class |
16 | |
17 | =head1 SYNOPSIS |
18 | |
b22c6668 |
19 | $resp = $c->response; |
b5176d9e |
20 | $resp->content_encoding; |
21 | $resp->content_length; |
22 | $resp->content_type; |
b22c6668 |
23 | $resp->cookies; |
aa64bada |
24 | $resp->header; |
b22c6668 |
25 | $resp->headers; |
26 | $resp->output; |
27 | $resp->redirect; |
28 | $resp->status; |
29 | |
30 | See also L<Catalyst::Application>. |
fc7ec1d9 |
31 | |
32 | =head1 DESCRIPTION |
33 | |
61b1e958 |
34 | This is the Catalyst Response class, which provides a set of accessors |
35 | to response data. |
b22c6668 |
36 | |
37 | =head1 METHODS |
fc7ec1d9 |
38 | |
b22c6668 |
39 | =over 4 |
fc7ec1d9 |
40 | |
b5176d9e |
41 | =item $resp->content_encoding |
42 | |
43 | Shortcut to $resp->headers->content_encoding |
44 | |
45 | =item $resp->content_length |
46 | |
47 | Shortcut to $resp->headers->content_length |
48 | |
49 | =item $resp->content_type |
50 | |
51 | Shortcut to $resp->headers->content_type |
52 | |
b22c6668 |
53 | =item $resp->cookies |
fc7ec1d9 |
54 | |
61b1e958 |
55 | Returns a reference to a hash containing the cookies to be set. |
fc7ec1d9 |
56 | |
57 | $c->response->cookies->{foo} = { value => '123' }; |
58 | |
b5176d9e |
59 | =item $resp->header |
60 | |
61 | Shortcut to $resp->headers->header |
62 | |
b22c6668 |
63 | =item $resp->headers |
fc7ec1d9 |
64 | |
65 | Returns a L<HTTP::Headers> object containing the headers. |
66 | |
67 | $c->response->headers->header( 'X-Catalyst' => $Catalyst::VERSION ); |
68 | |
b22c6668 |
69 | =item $resp->output($text) |
fc7ec1d9 |
70 | |
71 | Contains the final output. |
72 | |
61b1e958 |
73 | $c->response->output('Catalyst rocks!'); |
fc7ec1d9 |
74 | |
b22c6668 |
75 | =item $resp->redirect($url) |
fc7ec1d9 |
76 | |
77 | Contains a location to redirect to. |
78 | |
79 | $c->response->redirect('http://slashdot.org'); |
80 | |
b22c6668 |
81 | =item status |
fc7ec1d9 |
82 | |
83 | Contains the HTTP status. |
84 | |
85 | $c->response->status(404); |
86 | |
b22c6668 |
87 | =back |
88 | |
fc7ec1d9 |
89 | =head1 AUTHOR |
90 | |
91 | Sebastian Riedel, C<sri@cpan.org> |
61b1e958 |
92 | Marcus Ramberg, C<mramberg@cpan.org> |
fc7ec1d9 |
93 | |
94 | =head1 COPYRIGHT |
95 | |
61b1e958 |
96 | This program is free software, you can redistribute it and/or modify |
97 | it under the same terms as Perl itself. |
fc7ec1d9 |
98 | |
99 | =cut |
100 | |
101 | 1; |