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