PEF::Front::Request - HTTP request object from PSGI env hash
package My::Local::Test;
sub test { my ($msg, $context) = @_; return { result => "OK", data => [1, 2], path_info => $context->{request}->path_info }; }
PEF::Front::Request provides a consistent API for request objects across PEF::Front framework.
This module is intended to be used by web application developers only in rare circumstances. Developers can receive an object of this type in "Local", "InFilter" and "OutFilter" handlers via hash "context".
Unless otherwise noted, all methods and attributes are read-only, and passing values to the method like an accessor doesn't work like you expect it to.
PEF::Front::Request->new( $env );
Creates a new request object from supplied $env hash.
Returns the shared PSGI environment hash reference. This is a reference, so writing to this environment passes through during the whole PSGI request/response cycle.
Returns the IP address of the client (REMOTE_ADDR).
REMOTE_ADDR
Contains the request method (GET, POST, HEAD, etc) from HTTP protocol directly.
GET
POST
HEAD
Contains the request method (GET, POST, HEAD, etc) from HTTP protocol but it understands also X-HTTP-Method-Override header and WEBSOCKET, SSE types of request.
X-HTTP-Method-Override
WEBSOCKET
SSE
Returns the protocol (HTTP/1.0 or HTTP/1.1) used for the current request.
Returns the raw, undecoded request URI path. You probably do NOT want to use this to dispatch requests.
Returns PATH_INFO in the environment. Use this to get the local path for the requests.
Similar to path_info but can be changed during internal routing process. Decoded to utf8 perl internal representation.
path_info
Returns QUERY_STRING in the environment. This is the undecoded query string in the request URI.
Returns SCRIPT_NAME in the environment. This is the absolute path where your application is hosted. NOT TESTED
Returns the scheme (http or https) of the request.
http
https
Returns true or false, indicating whether the connection is secure (https).
Returns an URI object for the current request.
Every time this method is called it returns a new, cloned URI object.
Returns (optional) configured cfg_logger or psgix.logger code reference. When it exists, your application is supposed to send the log message to this logger, using:
cfg_logger
psgix.logger
$req->logger->({ level => 'debug', message => "This is a debug message" });
Returns a reference to a hash containing the cookies. Values are strings that are sent by clients and are URI decoded.
If there are multiple cookies with the same name in the request, this method will ignore the duplicates and return only the first value. If that causes issues for you, you may have to use modules like CGI::Simple::Cookie to parse <$request-header('Cookies')>> by yourself.
<$request-
Returns a hash reference containing (merged) GET and POST parameters.
Returns the request content in an undecoded byte string for POST requests.
Returns hostname of current request.
Returns full URL string of current request.
Returns REMOTE_USER if it's set.
REMOTE_USER
Returns an PEF::Front::HTTPHeaders object containing the headers for the current request.
Shortcut to $req->headers->get_header("content_encoding").
Returns length of content.
Returns Content-Type header value.
Shortcut to $req->headers->get_header.
Shortcut to $req->headers->get_header("referer").
Shortcut to $req->headers->get_header("user_agent").
Returns GET and POST parameters. This is an alternative method for accessing parameters in $req->params. It does allow setting or modifying query parameters.
Set/get/remove headers and cookies that will be copied into response object.
note($key, $value)
Set/get some extra info for request. Usefule during routing phase when context is not made up yet.
Anton Petrusevich.
Copyright (c) 2014 - 2016 Anton Petrusevich. Some Rights Reserved.
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
To install PEF::Front, copy and paste the appropriate command in to your terminal.
cpanm
cpanm PEF::Front
CPAN shell
perl -MCPAN -e shell install PEF::Front
For more information on module installation, please visit the detailed CPAN module installation guide.