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