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