++ed by:
ABRAXXA NEILB DRAEGTUN IOANR GETTY

68 PAUSE user(s)
32 non-PAUSE user(s).

Gisle Aas

NAME

HTTP::Headers - Class encapsulating HTTP Message headers

SYNOPSIS

 require HTTP::Headers;
 $request = new HTTP::Headers;

DESCRIPTION

HTTP::Headers is a class encapsulating HTTP style message headers: attribute value pairs which may be repeated, and are printed in a particular order.

Instances of this class are usually created as member variables of the HTTP::Request and HTTP::Response classes, internally to the library.

METHODS

new()

Constructs a new HTTP::Headers object. You might pass some initial headers as parameters to the constructor. E.g.:

 $h = new HTTP::Headers
     'Content-Type' => 'text/html',
     'MIME-Version' => '1.0',
     'Date'         => 'Thu, 03 Feb 1994 00:00:00 GMT';

clone()

Returns a copy of the object.

header($field [, $val],...)

Get/Set the value of a request header. The header field name is not case sensitive. The value argument may be a scalar or a reference to a list of scalars. If the value argument is not defined the header is not modified.

The method also accepts multiple ($field => $value) pairs.

The list of previous values for the last $field is returned. Only the first header value is returned in scalar context.

 $header->header('MIME-Version' => '1.0',
                 'User-Agent'   => 'My-Web-Client/0.01');
 $header->header('Accept' => "text/html, text/plain, image/*");
 @accepts = $header->header('Accept');

pushHeader($field, $val)

Add a new value to a field of the request header. The header field name is not case sensitive. The field need not already have a value. Duplicates are retained. The argument may be a scalar or a reference to a list of scalars.

 $header->pushHeader('Accept' => 'image/jpeg');

removeHeader($field,...)

This function removes the headers with the specified names.

scan(\&doit)

Apply the subroutine to each header in turn. The routine is called with two parameters; the name of the field and a single value. If the header has more than one value, then the routine is called once for each value. The scan() routine uses case for the field name as suggested by HTTP Spec, and follows recommended "Good Practice" of ordering the header fields.

asString([$endl])

Return the header fields as a formatted MIME header. Since it uses scan() to build the string, the result will use case as suggested by HTTP Spec, and it will follow recommended "Good Practice" of ordering the header fieds.