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