added convinient accessors to C::Request and C::Response
[catagits/Catalyst-Runtime.git] / lib / Catalyst / Response.pm
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
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
13 =head1 NAME
14
15 Catalyst::Response - Catalyst Response Class
16
17 =head1 SYNOPSIS
18
19     $resp = $c->response;
20     $resp->cookies;
21     $resp->headers;
22     $resp->output;
23     $resp->redirect;
24     $resp->status;
25
26 See also L<Catalyst::Application>.
27
28 =head1 DESCRIPTION
29
30 This is the Catalyst Response class, which provides a set of accessors to
31 response data.
32
33 =head1 METHODS
34
35 =over 4
36
37 =item $resp->cookies
38
39 Returns a reference to a hash containing the cookies.
40
41     $c->response->cookies->{foo} = { value => '123' };
42
43 =item $resp->headers
44
45 Returns a L<HTTP::Headers> object containing the headers.
46
47     $c->response->headers->header( 'X-Catalyst' => $Catalyst::VERSION );
48
49 =item $resp->output($text)
50
51 Contains the final output.
52
53     $c->response->output('Catalyst rockz!');
54
55 =item $resp->redirect($url)
56
57 Contains a location to redirect to.
58
59     $c->response->redirect('http://slashdot.org');
60
61 =item status
62
63 Contains the HTTP status.
64
65     $c->response->status(404);
66
67 =back
68
69 =head1 AUTHOR
70
71 Sebastian Riedel, C<sri@cpan.org>
72
73 =head1 COPYRIGHT
74
75 This program is free software, you can redistribute it and/or modify it under
76 the same terms as Perl itself.
77
78 =cut
79
80 1;