1 package Catalyst::Response;
4 use base 'Class::Accessor::Fast';
6 __PACKAGE__->mk_accessors(qw/cookies body headers location 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
23 $res->content_encoding;
34 See also L<Catalyst::Application>.
38 This is the Catalyst Response class, which provides a set of accessors
45 =item $res->body($text)
47 $c->response->body('Catalyst rocks!');
49 Contains the final output.
51 =item $res->content_encoding
53 Shortcut to $res->headers->content_encoding
55 =item $res->content_length
57 Shortcut to $res->headers->content_length
59 =item $res->content_type
61 Shortcut to $res->headers->content_type
65 Returns a reference to a hash containing the cookies to be set.
67 $c->response->cookies->{foo} = { value => '123' };
71 Shortcut to $res->headers->header
75 Returns a L<HTTP::Headers> object containing the headers.
77 $c->response->headers->header( 'X-Catalyst' => $Catalyst::VERSION );
81 Shortcut to $res->body
83 =item $res->redirect( $url, $status )
85 Contains a location to redirect to.
87 $c->response->redirect( 'http://slashdot.org' );
88 $c->response->redirect( 'http://slashdot.org', 307 );
97 my $status = shift || 302;
99 $self->location($location);
100 $self->status($status);
103 return $self->location;
108 Contains the HTTP status.
110 $c->response->status(404);
112 =item $res->write( $data )
114 Writes $data to the output stream.
118 sub write { shift->{_context}->write(@_); }
124 Sebastian Riedel, C<sri@cpan.org>
125 Marcus Ramberg, C<mramberg@cpan.org>
129 This program is free software, you can redistribute it and/or modify
130 it under the same terms as Perl itself.