GX::Response

Module Version: 0.2000_01

NAME

GX::Response - Response component

SYNOPSIS

package MyApp::Response;

use GX::Response;

1;

DESCRIPTION

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

METHODS

Constructor

new

Returns a new response object.

$response = $class->new( %attributes );
Attributes:
Returns:
Exceptions:

Public Methods

add

Adds the given content to the response body.

$response->add( @content );
Arguments:
  • @content ( scalars )

    • byte strings
    • references to byte strings
    • references to subroutines returning byte strings
    • IO::Handle objects / GLOB references to read() bytes from
Exceptions:

This method, which is inherited from GX::HTTP::Response, is a shortcut for calling $response->body->add().

body

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

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

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

content_encoding

Returns / sets the value of the "Content-Encoding" response header field.

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

This method, which is inherited from GX::HTTP::Response, is a shortcut for calling $response->headers->content_encoding().

content_length

Returns / sets the value of the "Content-Length" response header field.

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

This method, which is inherited from GX::HTTP::Response, is a shortcut for calling $response->headers->content_length().

content_type

Returns / sets the value of the "Content-Type" response header field.

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

This method, which is inherited from GX::HTTP::Response, is a shortcut for calling $response->headers->content_type().

cookie

Returns all response cookie objects with the given name in the order they were added to the cookies container.

@cookies = $response->cookie( $name );
Arguments:
  • $name ( string )
Returns:

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

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

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

cookies

Returns / sets the container for the response cookie objects.

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

has_body

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

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

has_cookies

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

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

has_headers

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

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

header

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

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

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

headers

Returns / sets the container for the response headers.

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

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

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, which is inherited from GX::HTTP::Response, is a shortcut for calling $response->headers->location().

protocol

Returns / sets the HTTP version.

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

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

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 )

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

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 )

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

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.