NAME
Catalyst::Request - Catalyst Request Class
SYNOPSIS
$req = $c->request;
$req->action;
$req->address;
$req->args;
$req->arguments;
$req->base;
$req->body;
$req->body_parameters;
$req->content_encoding;
$req->content_length;
$req->content_type;
$req->cookie;
$req->cookies;
$req->handle;
$req->header;
$req->headers;
$req->hostname;
$req->input;
$req->match;
$req->method;
$req->param;
$req->params;
$req->parameters;
$req->path;
$req->protocol;
$req->query_parameters;
$req->read;
$req->referer;
$req->secure;
$req->snippets;
$req->upload;
$req->uploads;
$req->uri;
$req->user;
$req->user_agent;
See also Catalyst.
DESCRIPTION
This is the Catalyst Request class, which provides a set of accessors to the request data. The request object is prepared by the specialized Catalyst Engine module thus hiding the details of the particular engine implementation.
METHODS
- $req->action
-
Contains the requested action.
print $c->request->action;
- $req->address
-
Contains the remote address.
print $c->request->address
- $req->args
-
Shortcut for arguments
- $req->arguments
-
Returns a reference to an array containing the arguments.
print $c->request->arguments->[0];
- $req->base
-
Contains the url base. This will always have a trailing slash.
- $req->body
-
Contains the message body of the request unless Content-Type is
application/x-www-form-urlencoded
ormultipart/form-data
.print $c->request->body
- $req->body_parameters
-
Returns a reference to a hash containing body parameters. Values can be either a scalar or an arrayref containing scalars.
print $c->request->body_parameters->{field}; print $c->request->body_parameters->{field}->[0];
- $req->body_params
-
An alias for body_parameters.
- $req->content_encoding
-
Shortcut to $req->headers->content_encoding
- $req->content_length
-
Shortcut to $req->headers->content_length
- $req->content_type
-
Shortcut to $req->headers->content_type
-
A convenient method to $req->cookies.
$cookie = $c->request->cookie('name'); @cookies = $c->request->cookie;
-
Returns a reference to a hash containing the cookies.
print $c->request->cookies->{mycookie}->value;
- $req->handle
-
Request IO handle.
- $req->header
-
Shortcut to $req->headers->header
- $req->headers
-
Returns an HTTP::Headers object containing the headers.
print $c->request->headers->header('X-Catalyst');
- $req->hostname
-
Lookup the current users DNS hostname.
print $c->request->hostname
- $req->input
-
Shortcut for $req->body.
- $req->match
-
This contains the matching part of a regexp action. Otherwise it returns the same as 'action'.
print $c->request->match;
- $req->method
-
Contains the request method (
GET
,POST
,HEAD
, etc).print $c->request->method;
- $req->param
-
Get request parameters with a CGI.pm-compatible param method. This is a method for accessing parameters in $c->req->parameters.
$value = $c->request->param('foo'); @values = $c->request->param('foo'); @params = $c->request->param;
- $req->params
-
Shortcut for $req->parameters.
- $req->parameters
-
Returns a reference to a hash containing parameters. Values can be either a scalar or an arrayref containing scalars.
print $c->request->parameters->{field}; print $c->request->parameters->{field}->[0];
- $req->path
-
Contains the path.
print $c->request->path;
- $req->path_info
-
alias for path, added for compability with CGI
- $req->protocol
-
Contains the protocol.
- $req->query_parameters
-
Returns a reference to a hash containing query parameters. Values can be either a scalar or an arrayref containing scalars.
print $c->request->query_parameters->{field}; print $c->request->query_parameters->{field}->[0];
- $req->read( [$maxlength] )
-
Read a chunk of data from the request body. This method is designed to be used in a while loop, reading $maxlength bytes on every call. $maxlength defaults to the size of the request if not specified.
You have to set MyApp->config->{parse_on_demand} to use this directly.
- $req->referer
-
Shortcut to $req->headers->referer. Referring page.
- $req->secure
-
Contains a boolean whether the communciation is secure.
- $req->snippets
-
Returns a reference to an array containing regex snippets.
my @snippets = @{ $c->request->snippets };
- $req->upload
-
A convenient method to $req->uploads.
$upload = $c->request->upload('field'); @uploads = $c->request->upload('field'); @fields = $c->request->upload; for my $upload ( $c->request->upload('field') ) { print $upload->filename; }
- $req->uploads
-
Returns a reference to a hash containing uploads. Values can be either a hashref or a arrayref containing
Catalyst::Request::Upload
objects.my $upload = $c->request->uploads->{field}; my $upload = $c->request->uploads->{field}->[0];
- $req->uri
-
Returns a URI object for the request.
- $req->user
-
Contains the user name of user if authentication check was successful.
- $req->user_agent
-
Shortcut to $req->headers->user_agent. User Agent version string.
AUTHOR
Sebastian Riedel, sri@cpan.org
Marcus Ramberg, mramberg@cpan.org
COPYRIGHT
This program is free software, you can redistribute it and/or modify it under the same terms as Perl itself.