1 package Catalyst::Request;
4 use base 'Class::Accessor::Fast';
6 __PACKAGE__->mk_accessors(
7 qw/action address arguments base cookies headers hostname match method
8 parameters path snippets uploads/
12 *params = \¶meters;
14 sub content_encoding { shift->headers->content_encoding(@_) }
15 sub content_length { shift->headers->content_length(@_) }
16 sub content_type { shift->headers->content_type(@_) }
17 sub header { shift->headers->header(@_) }
18 sub referer { shift->headers->referer(@_) }
19 sub user_agent { shift->headers->user_agent(@_) }
23 Catalyst::Request - Catalyst Request Class
34 $req->content_encoding;
55 This is the Catalyst Request class, which provides a set of accessors to the
56 request data. The request object is prepared by the specialized Catalyst
57 Engine module thus hiding the details of the particular engine implementation.
68 print $c->request->action;
72 Contains the remote address.
74 print $c->request->address
80 Returns a reference to an array containing the arguments.
82 print $c->request->arguments->[0];
86 Contains the uri base.
88 =item $req->content_encoding
90 Shortcut to $req->headers->content_encoding
92 =item $req->content_length
94 Shortcut to $req->headers->content_length
96 =item $req->content_type
98 Shortcut to $req->headers->content_type
102 Returns a reference to a hash containing the cookies.
104 print $c->request->cookies->{mycookie}->value;
108 Shortcut to $req->headers->header
112 Returns an L<HTTP::Headers> object containing the headers.
114 print $c->request->headers->header('X-Catalyst');
118 Contains the remote hostname.
120 print $c->request->hostname
126 print $c->request->match;
130 Contains the request method (C<GET>, C<POST>, C<HEAD>, etc).
132 print $c->request->method
134 =item $req->parameters
138 Returns a reference to a hash containing the parameters.
140 print $c->request->parameters->{foo};
146 print $c->request->path;
150 Shortcut to $req->headers->referer
154 Returns a reference to an array containing regex snippets.
156 my @snippets = @{ $c->request->snippets };
160 Returns a reference to a hash containing the uploads.
162 my $filename = $c->req->parameters->{foo};
163 print $c->request->uploads->{$filename}->{type};
164 print $c->request->uploads->{$filename}->{size};
165 my $fh = $c->request->uploads->{$filename}->{fh};
166 my $content = do { local $/; <$fh> };
168 =item $req->user_agent
170 Shortcut to $req->headers->user_agent
176 Sebastian Riedel, C<sri@cpan.org>
180 This program is free software, you can redistribute it and/or modify it under
181 the same terms as Perl itself.