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
49 This is the Catalyst Request class, which provides a set of accessors to the
50 request data. The request object is prepared by the specialized Catalyst
51 Engine module thus hiding the details of the particular engine implementation.
62 print $c->request->action;
66 Contains the remote address.
68 print $c->request->address
74 Returns a reference to an array containing the arguments.
76 print $c->request->arguments->[0];
80 Contains the uri base.
84 Returns a reference to a hash containing the cookies.
86 print $c->request->cookies->{mycookie}->value;
90 Returns an L<HTTP::Headers> object containing the headers.
92 print $c->request->headers->header('X-Catalyst');
96 Contains the remote hostname.
98 print $c->request->hostname
104 print $c->request->match;
106 =item $req->parameters
110 Returns a reference to a hash containing the parameters.
112 print $c->request->parameters->{foo};
118 print $c->request->path;
122 Contains the request method (C<GET>, C<POST>, C<HEAD>, etc).
124 print $c->request->method
128 Returns a reference to an array containing regex snippets.
130 my @snippets = @{ $c->request->snippets };
134 Returns a reference to a hash containing the uploads.
136 my $filename = $c->req->parameters->{foo};
137 print $c->request->uploads->{$filename}->{type};
138 print $c->request->uploads->{$filename}->{size};
139 my $fh = $c->request->uploads->{$filename}->{fh};
140 my $content = do { local $/; <$fh> };
146 Sebastian Riedel, C<sri@cpan.org>
150 This program is free software, you can redistribute it and/or modify it under
151 the same terms as Perl itself.