relative forwards call every matching private method!
[catagits/Catalyst-Runtime.git] / lib / Catalyst / Request.pm
CommitLineData
fc7ec1d9 1package Catalyst::Request;
2
3use strict;
4use base 'Class::Accessor::Fast';
5
6__PACKAGE__->mk_accessors(
0556eb49 7 qw/action address arguments base cookies headers hostname match method
8 parameters path snippets uploads/
fc7ec1d9 9);
10
11*args = \&arguments;
12*params = \&parameters;
13
f7e4e231 14sub content_encoding { shift->headers->content_encoding(@_) }
15sub content_length { shift->headers->content_length(@_) }
16sub content_type { shift->headers->content_type(@_) }
17sub header { shift->headers->header(@_) }
18sub referer { shift->headers->referer(@_) }
19sub user_agent { shift->headers->user_agent(@_) }
20
fc7ec1d9 21=head1 NAME
22
23Catalyst::Request - Catalyst Request Class
24
25=head1 SYNOPSIS
26
b22c6668 27
28 $req = $c->request;
29 $req->action;
30 $req->address;
31 $req->args;
32 $req->arguments;
33 $req->base;
b5176d9e 34 $req->content_encoding;
35 $req->content_length;
36 $req->content_type;
b22c6668 37 $req->cookies;
b5176d9e 38 $req->header;
b22c6668 39 $req->headers;
40 $req->hostname;
41 $req->match;
42 $req->method;
43 $req->parameters;
44 $req->params;
45 $req->path;
b5176d9e 46 $req->referer;
b22c6668 47 $req->snippets;
48 $req->uploads;
b5176d9e 49 $req->user_agent
b22c6668 50
51See also L<Catalyst>.
fc7ec1d9 52
53=head1 DESCRIPTION
54
b22c6668 55This is the Catalyst Request class, which provides a set of accessors to the
56request data. The request object is prepared by the specialized Catalyst
57Engine module thus hiding the details of the particular engine implementation.
58
59
60=head1 METHODS
fc7ec1d9 61
b22c6668 62=over 4
fc7ec1d9 63
b22c6668 64=item $req->action
fc7ec1d9 65
66Contains the action.
67
68 print $c->request->action;
69
b22c6668 70=item $req->address
0556eb49 71
72Contains the remote address.
73
74 print $c->request->address
75
b22c6668 76=item $req->arguments
fc7ec1d9 77
b22c6668 78=item $req->args
79
80Returns a reference to an array containing the arguments.
fc7ec1d9 81
82 print $c->request->arguments->[0];
83
b22c6668 84=item $req->base
fc7ec1d9 85
86Contains the uri base.
87
b5176d9e 88=item $req->content_encoding
89
90Shortcut to $req->headers->content_encoding
91
92=item $req->content_length
93
94Shortcut to $req->headers->content_length
95
96=item $req->content_type
97
98Shortcut to $req->headers->content_type
99
b22c6668 100=item $req->cookies
fc7ec1d9 101
b22c6668 102Returns a reference to a hash containing the cookies.
fc7ec1d9 103
104 print $c->request->cookies->{mycookie}->value;
105
b5176d9e 106=item $req->header
107
108Shortcut to $req->headers->header
109
b22c6668 110=item $req->headers
fc7ec1d9 111
b22c6668 112Returns an L<HTTP::Headers> object containing the headers.
fc7ec1d9 113
114 print $c->request->headers->header('X-Catalyst');
115
b22c6668 116=item $req->hostname
0556eb49 117
118Contains the remote hostname.
119
120 print $c->request->hostname
121
b22c6668 122=item $req->match
fc7ec1d9 123
124Contains the match.
125
126 print $c->request->match;
127
b5176d9e 128=item $req->method
129
130Contains the request method (C<GET>, C<POST>, C<HEAD>, etc).
131
132 print $c->request->method
133
b22c6668 134=item $req->parameters
135
136=item $req->params
fc7ec1d9 137
b22c6668 138Returns a reference to a hash containing the parameters.
fc7ec1d9 139
140 print $c->request->parameters->{foo};
141
b22c6668 142=item $req->path
fc7ec1d9 143
144Contains the path.
145
146 print $c->request->path;
147
b5176d9e 148=item $req->referer
fc7ec1d9 149
b5176d9e 150Shortcut to $req->headers->referer
fc7ec1d9 151
b22c6668 152=item $req->snippets
fc7ec1d9 153
b22c6668 154Returns a reference to an array containing regex snippets.
fc7ec1d9 155
156 my @snippets = @{ $c->request->snippets };
157
b22c6668 158=item $req->uploads
fc7ec1d9 159
b22c6668 160Returns a reference to a hash containing the uploads.
fc7ec1d9 161
7833fdfc 162 my $filename = $c->req->parameters->{foo};
0ea0c2c3 163 print $c->request->uploads->{$filename}->{type};
164 print $c->request->uploads->{$filename}->{size};
165 my $fh = $c->request->uploads->{$filename}->{fh};
7833fdfc 166 my $content = do { local $/; <$fh> };
fc7ec1d9 167
b5176d9e 168=item $req->user_agent
169
170Shortcut to $req->headers->user_agent
171
b22c6668 172=back
173
fc7ec1d9 174=head1 AUTHOR
175
176Sebastian Riedel, C<sri@cpan.org>
177
178=head1 COPYRIGHT
179
180This program is free software, you can redistribute it and/or modify it under
181the same terms as Perl itself.
182
183=cut
184
1851;