1 package Catalyst::Response;
4 use base 'Class::Accessor::Fast';
6 __PACKAGE__->mk_accessors(qw/cookies body headers redirect status/);
10 sub content_encoding { shift->headers->content_encoding(@_) }
11 sub content_length { shift->headers->content_length(@_) }
12 sub content_type { shift->headers->content_type(@_) }
13 sub header { shift->headers->header(@_) }
17 Catalyst::Response - Catalyst Response Class
25 $resp->content_encoding;
26 $resp->content_length;
35 See also L<Catalyst::Application>.
39 This is the Catalyst Response class, which provides a set of accessors
46 =item $resp->body($text)
48 $c->response->body('Catalyst rocks!');
50 Contains the final output.
52 =item $resp->body_length
54 Returns the length of body in bytes.
56 print $c->response->body_length
65 return 0 unless $self->body;
66 return length($self->body);
71 Returns a reference to body.
77 return \$self->{body};
80 =item $resp->content_encoding
82 Shortcut to $resp->headers->content_encoding
84 =item $resp->content_length
86 Shortcut to $resp->headers->content_length
88 =item $resp->content_type
90 Shortcut to $resp->headers->content_type
94 Returns a reference to a hash containing the cookies to be set.
96 $c->response->cookies->{foo} = { value => '123' };
100 Shortcut to $resp->headers->header
104 Returns a L<HTTP::Headers> object containing the headers.
106 $c->response->headers->header( 'X-Catalyst' => $Catalyst::VERSION );
110 Shortcut to $resp->body
112 =item $resp->redirect($url)
114 Contains a location to redirect to.
116 $c->response->redirect('http://slashdot.org');
120 Contains the HTTP status.
122 $c->response->status(404);
128 Sebastian Riedel, C<sri@cpan.org>
129 Marcus Ramberg, C<mramberg@cpan.org>
133 This program is free software, you can redistribute it and/or modify
134 it under the same terms as Perl itself.