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