GX::Request

Module Version: 0.2000_01

NAME

GX::Request - Request component

SYNOPSIS

package MyApp::Request;

use GX::Request;

1;

DESCRIPTION

This module provides the GX::Request class which inherits directly from GX::Component and GX::HTTP::Request.

METHODS

Constructor

new

Returns a new request object.

$request = $class->new( %attributes );
Attributes:
  • body ( GX::HTTP::Body object )

    A GX::HTTP::Body object encapsulating the request body. Defaults to a GX::HTTP::Body::Scalar object.

  • body_parameters ( GX::HTTP::Parameters object )

    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 )

    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 )

    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 )

    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 )

    A GX::HTTP::Request::Headers object containing the request headers. Initialized on demand.

  • host ( string | undef )

    A string with the name of the host or undef if the name is unknown.

  • method ( string | undef )

    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 )

    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 )

    A string with the path portion of the request URI or undef if the path is not determinable.

  • path_parameters ( GX::HTTP::Parameters object )

    A GX::HTTP::Parameters object containing the path parameters. Initialized on demand.

  • port ( integer | undef )

    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 )

    A string identifying the HTTP version (for example "HTTP/1.1") or undef if the protocol version is unknown.

  • query ( string | undef )

    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 )

    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 )

    A read progress callback.

  • remote_address ( string | undef )

    A string with the IP address of the client or undef if the address is unknown.

  • scheme ( string | undef )

    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 )

    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 )

    A string with the request URI as sent by the client or undef if the URI is unknown.

Returns:
Exceptions:

Public Methods

body

Returns / sets the GX::HTTP::Body object containing the request body.

$body = $request->body;
$body = $request->body( $body );
Arguments:
Returns:

This method is inherited from GX::HTTP::Request.

body_parameters

Returns / sets the container for the request body parameters.

$parameters = $request->body_parameters;
$parameters = $request->body_parameters( $parameters );
Arguments:
Returns:

body_parser

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 );
Arguments:
Returns:
  • $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 );
Arguments:
  • $content_encoding ( string | undef ) [ optional ]
Returns:
  • $content_encoding ( string | undef )

This method, which is inherited from GX::HTTP::Request, is a shortcut for calling $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 );
Arguments:
  • $content_length ( string | undef ) [ optional ]
Returns:
  • $content_length ( string | undef )

This method, which is inherited from GX::HTTP::Request, is a shortcut for calling $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 );
Arguments:
  • $content_type ( string | undef ) [ optional ]
Returns:
  • $content_type ( string | undef )

This method, which is inherited from GX::HTTP::Request, is a shortcut for calling $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 );
Arguments:
  • $name ( string )
Returns:

In scalar context, the first of those objects is returned.

$cookie = $request->cookie( $name );
Arguments:
  • $name ( string )
Returns:

This method is a shortcut for calling $request->cookies->get().

cookies

Returns / sets the container for the request cookie objects.

$cookies = $request->cookies;
$cookies = $request->cookies( $cookies );
Arguments:
Returns:

format

Returns / sets the string identifying the requested response format.

$format = $request->format;
$format = $request->format( $format );
Arguments:
  • $format ( string | undef ) [ optional ]
Returns:
  • $format ( string | undef )

has_body

Returns true if the request body is not empty, otherwise false.

$bool = $request->has_body;
Returns:
  • $bool ( bool )

has_cookies

Returns true if the request cookies container is not empty, otherwise false.

$bool = $request->has_cookies;
Returns:
  • $bool ( bool )

has_headers

Returns true if the request headers container is not empty, otherwise false.

$bool = $request->has_headers;
Returns:
  • $bool ( bool )

has_parameters

Returns true if the parameters container is not empty, otherwise false.

$bool = $request->has_parameters;
Returns:
  • $bool ( bool )

has_uploads

Returns true if the uploads container is not empty, otherwise false.

$bool = $request->has_uploads;
Returns:
  • $bool ( bool )

header

Returns / sets the value of the specified request header field.

$value = $request->header( $field );
$value = $request->header( $field, $value );
Arguments:
  • $field ( string )
  • $value ( string | undef ) [ optional ]
Returns:
  • $value ( string | undef )

This method is inherited from GX::HTTP::Request.

headers

Returns / sets the container for the request headers.

$headers = $request->headers;
$headers = $request->headers( $headers );
Arguments:
Returns:

This method is inherited from GX::HTTP::Request.

host

Returns / sets the hostname.

$host = $request->host;
$host = $request->host( $host );
Arguments:
  • $host ( string | undef ) [ optional ]
Returns:
  • $host ( string | undef )

method

Returns / sets the request method.

$method = $request->method;
$method = $request->method( $method );
Arguments:
  • $method ( string | undef ) [ optional ]
Returns:
  • $method ( string | undef )

This method is inherited from GX::HTTP::Request.

parameter

Returns the values associated with the given parameter key in the order they were added to the parameters container.

@values = $request->parameter( $key );
Arguments:
  • $key ( string )
Returns:
  • @values ( strings )

In scalar context, the first of those values is returned.

$value = $request->parameter( $key );
Arguments:
  • $key ( string )
Returns:
  • $value ( string | undef )

This method is a shortcut for calling $request->parameters->get().

parameters

Returns / sets the container for the merged path, query and body parameters.

$parameters = $request->parameters;
$parameters = $request->parameters( $parameters );
Arguments:
Returns:

path

Returns / sets the requested path.

$path = $request->path;
$path = $request->path( $path );
Arguments:
  • $path ( string | undef ) [ optional ]
Returns:
  • $path ( string | undef )

path_parameters

Returns / sets the container for the path parameters.

$parameters = $request->path_parameters;
$parameters = $request->path_parameters( $parameters );
Arguments:
Returns:

port

Returns / sets the port number on which the request was received from the client.

$port = $request->port;
$port = $request->port( $port );
Arguments:
  • $port ( integer | undef ) [ optional ]
Returns:
  • $port ( integer | undef )

protocol

Returns / sets the HTTP version.

$protocol = $request->protocol;
$protocol = $request->protocol( $protocol );
Arguments:
  • $protocol ( string | undef ) [ optional ]
Returns:
  • $protocol ( string | undef )

This method is inherited from GX::HTTP::Request.

query

Returns / sets the query string.

$query = $request->query;
$query = $request->query( $query );
Arguments:
  • $query ( string | undef ) [ optional ]
Returns:
  • $query ( string | undef )

query_parameters

Returns / sets the container for the query parameters.

$parameters = $request->query_parameters;
$parameters = $request->query_parameters( $parameters );
Arguments:
Returns:

read_callback

Returns / sets the read progress callback.

$code = $request->read_callback;
$code = $request->read_callback( $code );
Arguments:
  • $code ( CODE reference | undef ) [ optional ]
Returns:
  • $code ( CODE reference | undef )

referer

Returns / sets the value of the "Referer" header field.

$referer = $request->referer;
$referer = $request->referer( $referer );
Arguments:
  • $referer ( string | undef ) [ optional ]
Returns:
  • $referer ( string | undef )

This method, which is inherited from GX::HTTP::Request, is a shortcut for calling $request->headers->referer().

remote_address

Returns / sets the IP address of the client.

$address = $request->remote_address;
$address = $request->remote_address( $address );
Arguments:
  • $address ( string | undef ) [ optional ]
Returns:
  • $address ( string | undef )

scheme

Returns / sets the request scheme.

$scheme = $request->scheme;
$scheme = $request->scheme( $scheme );
Arguments:
  • $scheme ( string | undef ) [ optional ]
Returns:
  • $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 );
Arguments:
  • $name ( string )
Returns:

In scalar context, the first of those objects is returned.

$upload = $request->upload( $name );
Arguments:
  • $name ( string )
Returns:

This method is a shortcut for calling $request->uploads->get().

uploads

Returns / sets the container for the upload objects.

$uploads = $request->uploads;
$uploads = $request->uploads( $uploads );
Arguments:
Returns:

uri

Returns / sets the request URI.

$uri = $request->uri;
$uri = $request->uri( $uri );
Arguments:
  • $uri ( string | undef ) [ optional ]
Returns:
  • $uri ( string | undef )

This method is inherited from GX::HTTP::Request.

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 );
Arguments:
  • $user_agent ( string | undef ) [ optional ]
Returns:
  • $user_agent ( string | undef )

This method, which is inherited from GX::HTTP::Request, is a shortcut for calling $request->headers->user_agent().

AUTHOR

Jörg A. Uzarek <uzarek@runlevelnull.de>

COPYRIGHT AND LICENSE

Copyright © 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.