GX::HTTP::Message

Module Version: 0.2000_01

NAME

GX::HTTP::Message - HTTP message base class

SYNOPSIS

None.

DESCRIPTION

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

METHODS

Constructor

This class is not meant to be instantiated. See GX::HTTP::Request and GX::HTTP::Response instead.

Public Methods

add

Adds the given content to the message body.

$message->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 is a shortcut for calling $message->body->add().

as_string

Returns the message as a string of bytes.

$string = $message->as_string;
Returns:
  • $string ( string )
Exceptions:

body

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

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

content_encoding

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

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

This method is a shortcut for calling $message->headers->content_encoding().

content_length

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

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

This method is a shortcut for calling $message->headers->content_length().

content_type

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

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

This method is a shortcut for calling $message->headers->content_type().

header

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

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

This method is a shortcut for calling $message->headers->get() and $message->headers->set() respectively.

headers

Returns / sets the container for the message headers.

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

print

An alias for the add() method.

$message->print( @content );

print_to

Prints the message to the specified filehandle, returning true on success and false on failure.

$result = $message->print_to( $handle );
Arguments:
  • $handle ( IO::File object | typeglob | GLOB reference )
Returns:
  • $result ( bool )
Exceptions:

protocol

Returns / sets the HTTP version.

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

SUBCLASSES

The following classes inherit directly from GX::HTTP::Message:

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.