GX::HTTP::Request

Module Version: 0.2000_01

NAME

GX::HTTP::Request - HTTP request class

SYNOPSIS

# Load the class
use GX::HTTP::Request;

# Create a new request object
$request = GX::HTTP::Request->new(
protocol => 'HTTP/1.1',
method => 'GET',
uri => 'http://www.gxframework.org/'
);

# Print the request
$request->print_to( *STDOUT );

DESCRIPTION

This module provides the GX::HTTP::Request class which extends the GX::HTTP::Message class.

METHODS

Constructor

new

Returns a new GX::HTTP::Request object.

$request = GX::HTTP::Request->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.

  • headers ( GX::HTTP::Request::Headers object )

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

  • method ( string | undef )

    A string identifying the HTTP request method (for example "GET", "POST" or "HEAD") or undef if the method is unknown.

  • protocol ( string | undef )

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

  • uri ( string | undef )

    A string with the request URI or undef if the URI is unknown.

Returns:
Exceptions:

Public Methods

as_string

See GX::HTTP::Message.

content_encoding

See GX::HTTP::Message.

content_length

See GX::HTTP::Message.

content_type

See GX::HTTP::Message.

headers

See GX::HTTP::Message.

method

Returns / sets the request method.

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

See RFC 2616, section 5.1.1 for a list of all HTTP/1.1 request methods.

print_to

See GX::HTTP::Message.

protocol

See GX::HTTP::Message.

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 is a shortcut for calling $request->headers->referer().

request_line

Constructs the request line and returns it.

$request_line = $request->request_line;
Returns:
  • $request_line ( string )
Exceptions:

See RFC 2616, section 5.1.

uri

Returns / sets the request URI.

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

See RFC 2616, section 5.1.2.

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