GX::Request - Request component
package MyApp::Request; use GX::Request; 1;
This module provides the GX::Request class which inherits directly from GX::Component and GX::HTTP::Request.
new
Returns a new request object.
$request = $class->new( %attributes );
body ( GX::HTTP::Body object )
body
A GX::HTTP::Body object encapsulating the request body. Defaults to a GX::HTTP::Body::Scalar object.
body_parameters ( GX::HTTP::Parameters object )
body_parameters
A GX::HTTP::Parameters object containing the request body parameters. Unless set explicitly, this attribute is initialized on-demand, which triggers the parsing of the request body.
body_parser ( GX::HTTP::Parser::Body object | undef )
body_parser
undef
A GX::HTTP::Parser::Body instance that should be used for parsing the request body. This attribute is initialized on demand. Setting it to undef disables the (on-demand) parsing of the request body.
cookies ( GX::HTTP::Request::Cookies object )
cookies
A GX::HTTP::Request::Cookies object containing the cookies that were sent with the request. Unless set explicitly, this attribute is initialized on-demand, which triggers the parsing of the request headers.
format ( string | undef )
format
A string identifying the requested response format (for example "html" or "xml") or undef if a response format has not been specified.
headers ( GX::HTTP::Request::Headers object )
headers
A GX::HTTP::Request::Headers object containing the request headers. Initialized on demand.
host ( string | undef )
host
A string with the name of the host or undef if the name is unknown.
method ( string | undef )
method
A string identifying the HTTP request method (for example "GET", "POST" or "HEAD") or undef if the method is unknown.
parameters ( GX::HTTP::Parameters object )
parameters
A GX::HTTP::Parameters object containing the merged path, query and body parameters. Unless set explicitly, this attribute is initialized on-demand, which triggers the parsing of both the request body and the query string portion of the request URI.
path ( string | undef )
path
A string with the path portion of the request URI or undef if the path is not determinable.
path_parameters ( GX::HTTP::Parameters object )
path_parameters
A GX::HTTP::Parameters object containing the path parameters. Initialized on demand.
port ( integer | undef )
port
The TCP/IP port number on which the request was received from the client or undef if the port number is unknown.
protocol ( string | undef )
protocol
A string identifying the HTTP version (for example "HTTP/1.1") or undef if the protocol version is unknown.
query ( string | undef )
query
A string with the query portion of the request URI or undef if the query string is not determinable.
query_parameters ( GX::HTTP::Parameters object )
query_parameters
A GX::HTTP::Parameters object containing the query parameters. Unless set explicitly, this attribute is initialized on-demand, which triggers the parsing of the query portion of the request URI.
read_callback ( CODE reference | undef )
read_callback
CODE
A read progress callback.
remote_address ( string | undef )
remote_address
A string with the IP address of the client or undef if the address is unknown.
scheme ( string | undef )
scheme
A string with the scheme portion of the request URI (for example "http" or "https") or undef if the scheme is not determinable.
uploads ( GX::HTTP::Uploads object )
uploads
A GX::HTTP::Uploads object containing the uploads that were sent with the request. Unless set explicitly, this attribute is initialized on-demand, which triggers the parsing of the request body.
uri ( string | undef )
uri
A string with the request URI as sent by the client or undef if the URI is unknown.
$request ( GX::Request object )
$request
GX::Exception
Returns / sets the GX::HTTP::Body object containing the request body.
$body = $request->body; $body = $request->body( $body );
$body ( GX::HTTP::Body object ) [ optional ]
$body
$body ( GX::HTTP::Body object )
This method is inherited from GX::HTTP::Request.
Returns / sets the container for the request body parameters.
$parameters = $request->body_parameters; $parameters = $request->body_parameters( $parameters );
$parameters ( GX::HTTP::Parameters object ) [ optional ]
$parameters
$parameters ( GX::HTTP::Parameters object )
Returns / sets the GX::HTTP::Parser::Body instance that is used for parsing the request body.
$parser = $request->body_parser; $parser = $request->body_parser( $parser );
$parser ( GX::HTTP::Parser::Body object | undef ) [ optional ]
$parser
$parser ( GX::HTTP::Parser::Body object | undef )
Passing undef disables the (on-demand) parsing of the request body.
content_encoding
Returns / sets the value of the "Content-Encoding" request header field.
$content_encoding = $request->content_encoding; $content_encoding = $request->content_encoding( $content_encoding );
$content_encoding ( string | undef ) [ optional ]
$content_encoding
$content_encoding ( string | undef )
This method, which is inherited from GX::HTTP::Request, is a shortcut for calling $request->headers->content_encoding().
$request->headers->content_encoding()
content_length
Returns / sets the value of the "Content-Length" request header field.
$content_length = $request->content_length; $content_length = $request->content_length( $content_length );
$content_length ( string | undef ) [ optional ]
$content_length
$content_length ( string | undef )
This method, which is inherited from GX::HTTP::Request, is a shortcut for calling $request->headers->content_length().
$request->headers->content_length()
content_type
Returns / sets the value of the "Content-Type" request header field.
$content_type = $request->content_type; $content_type = $request->content_type( $content_type );
$content_type ( string | undef ) [ optional ]
$content_type
$content_type ( string | undef )
This method, which is inherited from GX::HTTP::Request, is a shortcut for calling $request->headers->content_type().
$request->headers->content_type()
cookie
Returns all request cookie objects with the given name in the order they were added to the cookies container.
@cookies = $request->cookie( $name );
$name ( string )
$name
@cookies ( GX::HTTP::Request::Cookie objects )
@cookies
In scalar context, the first of those objects is returned.
$cookie = $request->cookie( $name );
$cookie ( GX::HTTP::Request::Cookie object | undef )
$cookie
This method is a shortcut for calling $request->cookies->get().
$request->cookies->get()
Returns / sets the container for the request cookie objects.
$cookies = $request->cookies; $cookies = $request->cookies( $cookies );
$cookies ( GX::HTTP::Request::Cookies object ) [ optional ]
$cookies
$cookies ( GX::HTTP::Request::Cookies object )
Returns / sets the string identifying the requested response format.
$format = $request->format; $format = $request->format( $format );
$format ( string | undef ) [ optional ]
$format
$format ( string | undef )
has_body
Returns true if the request body is not empty, otherwise false.
$bool = $request->has_body;
$bool ( bool )
$bool
has_cookies
Returns true if the request cookies container is not empty, otherwise false.
$bool = $request->has_cookies;
has_headers
Returns true if the request headers container is not empty, otherwise false.
$bool = $request->has_headers;
has_parameters
Returns true if the parameters container is not empty, otherwise false.
$bool = $request->has_parameters;
has_uploads
Returns true if the uploads container is not empty, otherwise false.
$bool = $request->has_uploads;
header
Returns / sets the value of the specified request header field.
$value = $request->header( $field ); $value = $request->header( $field, $value );
$field ( string )
$field
$value ( string | undef ) [ optional ]
$value
$value ( string | undef )
Returns / sets the container for the request headers.
$headers = $request->headers; $headers = $request->headers( $headers );
$headers ( GX::HTTP::Request::Headers ) [ optional ]
$headers
$headers ( GX::HTTP::Request::Headers )
Returns / sets the hostname.
$host = $request->host; $host = $request->host( $host );
$host ( string | undef ) [ optional ]
$host
$host ( string | undef )
Returns / sets the request method.
$method = $request->method; $method = $request->method( $method );
$method ( string | undef ) [ optional ]
$method
$method ( string | undef )
parameter
Returns the values associated with the given parameter key in the order they were added to the parameters container.
@values = $request->parameter( $key );
$key ( string )
$key
@values ( strings )
@values
In scalar context, the first of those values is returned.
$value = $request->parameter( $key );
This method is a shortcut for calling $request->parameters->get().
$request->parameters->get()
Returns / sets the container for the merged path, query and body parameters.
$parameters = $request->parameters; $parameters = $request->parameters( $parameters );
Returns / sets the requested path.
$path = $request->path; $path = $request->path( $path );
$path ( string | undef ) [ optional ]
$path
$path ( string | undef )
Returns / sets the container for the path parameters.
$parameters = $request->path_parameters; $parameters = $request->path_parameters( $parameters );
Returns / sets the port number on which the request was received from the client.
$port = $request->port; $port = $request->port( $port );
$port ( integer | undef ) [ optional ]
$port
$port ( integer | undef )
Returns / sets the HTTP version.
$protocol = $request->protocol; $protocol = $request->protocol( $protocol );
$protocol ( string | undef ) [ optional ]
$protocol
$protocol ( string | undef )
Returns / sets the query string.
$query = $request->query; $query = $request->query( $query );
$query ( string | undef ) [ optional ]
$query
$query ( string | undef )
Returns / sets the container for the query parameters.
$parameters = $request->query_parameters; $parameters = $request->query_parameters( $parameters );
Returns / sets the read progress callback.
$code = $request->read_callback; $code = $request->read_callback( $code );
$code ( CODE reference | undef ) [ optional ]
$code
$code ( CODE reference | undef )
referer
Returns / sets the value of the "Referer" header field.
$referer = $request->referer; $referer = $request->referer( $referer );
$referer ( string | undef ) [ optional ]
$referer
$referer ( string | undef )
This method, which is inherited from GX::HTTP::Request, is a shortcut for calling $request->headers->referer().
$request->headers->referer()
Returns / sets the IP address of the client.
$address = $request->remote_address; $address = $request->remote_address( $address );
$address ( string | undef ) [ optional ]
$address
$address ( string | undef )
Returns / sets the request scheme.
$scheme = $request->scheme; $scheme = $request->scheme( $scheme );
$scheme ( string | undef ) [ optional ]
$scheme
$scheme ( string | undef )
upload
Returns all upload objects with the given name in the order they were added to the uploads container.
@uploads = $request->upload( $name );
@uploads ( GX::HTTP::Upload objects )
@uploads
$upload = $request->upload( $name );
$upload ( GX::HTTP::Upload object | undef )
$upload
This method is a shortcut for calling $request->uploads->get().
$request->uploads->get()
Returns / sets the container for the upload objects.
$uploads = $request->uploads; $uploads = $request->uploads( $uploads );
$uploads ( GX::HTTP::Uploads object ) [ optional ]
$uploads
$uploads ( GX::HTTP::Uploads object )
Returns / sets the request URI.
$uri = $request->uri; $uri = $request->uri( $uri );
$uri ( string | undef ) [ optional ]
$uri
$uri ( string | undef )
user_agent
Returns / sets the value of the "User-Agent" request header field.
$user_agent = $request->user_agent; $user_agent = $request->user_agent( $user_agent );
$user_agent ( string | undef ) [ optional ]
$user_agent
$user_agent ( string | undef )
This method, which is inherited from GX::HTTP::Request, is a shortcut for calling $request->headers->user_agent().
$request->headers->user_agent()
Jörg A. Uzarek <uzarek@runlevelnull.de>
Copyright (c) 2009-2011 Jörg A. Uzarek.
This module is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License Version 3 as published by the Free Software Foundation.
To install GX, copy and paste the appropriate command in to your terminal.
cpanm
cpanm GX
CPAN shell
perl -MCPAN -e shell install GX
For more information on module installation, please visit the detailed CPAN module installation guide.