The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

GX::HTTP::Response::Headers - HTTP response headers class

SYNOPSIS

    # Load the class
    use GX::HTTP::Response::Headers;
    
    # Create a new headers object
    $headers = GX::HTTP::Response::Headers->new;
    
    # Set the value of a header field
    $headers->set( 'Content-Type' => 'text/plain' );
    
    # Get the value of a header field
    $content_type = $headers->get( 'Content-Type' );
    
    # Print the headers
    print $headers->as_string;

DESCRIPTION

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

METHODS

Constructor

new

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

    $headers = GX::HTTP::Response::Headers->new;
Returns:
Exceptions:

Also see parse().

Basic Public API

add

See "add" in GX::HTTP::Headers.

as_string

See "as_string" in GX::HTTP::Headers.

clear

See "clear" in GX::HTTP::Headers.

count

See "count" in GX::HTTP::Headers.

field_names

See "field_names" in GX::HTTP::Headers.

get

See "get" in GX::HTTP::Headers.

parse

Parses the given message header and adds the resulting header field / value pairs to the container.

    $headers->parse( $string );
Arguments:
  • $string ( string )

This method can also be used as a constructor.

    $headers = GX::HTTP::Response::Headers->parse( $string );
Arguments:
  • $string ( string )

Returns:
Exceptions:

remove

See "remove" in GX::HTTP::Headers.

set

See "set" in GX::HTTP::Headers.

sorted_field_names

See "sorted_field_names" in GX::HTTP::Headers.

Public Field Accessors

content_disposition

See "content_disposition" in GX::HTTP::Headers.

content_encoding

See "content_encoding" in GX::HTTP::Headers.

content_language

See "content_language" in GX::HTTP::Headers.

content_length

See "content_length" in GX::HTTP::Headers.

content_type

See "content_type" in GX::HTTP::Headers.

date

See "date" in GX::HTTP::Headers.

expires

See "expires" in GX::HTTP::Headers.

last_modified

See "last_modified" in GX::HTTP::Headers.

location

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

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

Returns:
  • $value ( string | undef )

See RFC 2616, section 14.30.

Returns / sets the value of the "Set-Cookie" header field.

    $value = $headers->set_cookie;
    $value = $headers->set_cookie( $value );
Arguments:
  • $value ( string | undef ) [ optional ]

Returns:
  • $value ( string | undef )

See RFC 2109, section 4.2.2.

AUTHOR

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

COPYRIGHT AND LICENSE

Copyright (c) 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.