GX::HTTP::Response

Module Version: 0.2000_01

NAME

GX::HTTP::Response - HTTP response class

SYNOPSIS

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

# Create a new response object
$response = GX::HTTP::Response->new(
protocol => 'HTTP/1.1',
status => 200
);

# Add content
$response->add( 'Hello world!' );

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

DESCRIPTION

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

METHODS

Constructor

new

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

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

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

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

    A GX::HTTP::Response::Headers object containing the response headers. Initialized on demand.

  • protocol ( string | undef )

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

  • status ( integer | undef )

    A HTTP status code (for example "200" or "404") or undef if the status is unknown.

  • status_reason ( string | undef )

    A string with the status reason phrase or undef if the reason phrase is undefined.

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.

location

Returns / sets the value of the "Location" response header field.

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

This method is a shortcut for calling $response->headers->location().

print_to

See GX::HTTP::Message.

protocol

See GX::HTTP::Message.

status

Returns / sets the status code of the response.

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

See RFC 2616, section 6.1.1

status_line

Constructs the status line and returns it.

$status_line = $response->status_line;
Returns:
  • $status_line ( string )
Exceptions:

See RFC 2616, section 6.1

status_reason

Returns / sets the status reason phrase.

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

See RFC 2616, section 6.1.1

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.