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. The keys of the
66 hash are the cookies' names, and their corresponding values are hash references
67 used to construct L<CGI::Cookie> object.
69 $c->response->cookies->{foo} = { value => '123' };
71 The values correspond to the L<CGI::Cookie> parameters of the same name, except
72 they are used without a leading dash.
74 The proxied parameters are
94 Shortcut to $res->headers->header
98 Returns a L<HTTP::Headers> object containing the headers.
100 $c->response->headers->header( 'X-Catalyst' => $Catalyst::VERSION );
104 Shortcut to $res->body
106 =item $res->redirect( $url, $status )
108 Contains a location to redirect to.
110 $c->response->redirect( 'http://slashdot.org' );
111 $c->response->redirect( 'http://slashdot.org', 307 );
119 my $location = shift;
120 my $status = shift || 302;
122 $self->location($location);
123 $self->status($status);
126 return $self->location;
131 Contains the HTTP status.
133 $c->response->status(404);
135 =item $res->write( $data )
137 Writes $data to the output stream.
141 sub write { shift->{_context}->write(@_); }
147 Sebastian Riedel, C<sri@cpan.org>
148 Marcus Ramberg, C<mramberg@cpan.org>
152 This program is free software, you can redistribute it and/or modify
153 it under the same terms as Perl itself.