Andy Armstrong > APR-HTTP-Headers-Compat-0.02 > APR::HTTP::Headers::Compat

Download:
APR-HTTP-Headers-Compat-0.02.tar.gz

Dependencies

Annotate this POD

View/Report Bugs
Module Version: 0.02   Source  

NAME ^

APR::HTTP::Headers::Compat - Make an APR::Table look like an HTTP::Headers

VERSION ^

This document describes APR::HTTP::Headers::Compat version 0.02

SYNOPSIS ^

  use APR::HTTP::Headers::Compat;

  # We're running under mod_perl2...
  my $hdrs = APR::HTTP::Headers::Compat->new( $r->headers_out );

  # Now we can treat $hdrs as if it was an HTTP::Headers
  $hdrs->header( 'Content-Type' => 'text/plain' );

DESCRIPTION ^

Under mod_perl HTTP headers are stashed in APR::Table objects. Sometimes you will encounter code (such as FirePHP::Dispatcher) that needs an HTTP::Headers. This module wraps an APR::Table in a subclass of HTTP::Headers so that it can be used wherever an HTTP::Headers is expected.

Synchronisation is bi-directional; changes via the HTTP::Headers interface are reflected immediately in the underlying APR::Table and direct changes to the table show up immediately in the wrapper.

INTERFACE ^

Unless otherwise stated below all methods are inherited from HTTP::Headers.

new

Create a new wrapper around an existing APR::Table.

  # Normally you'll be given the table - we're creating one here for the
  # sake of the example
  my $table = APR::Table::make( APR::Pool->new, 1 );

  # Wrap the table so it can be used as an HTTP::Headers instance
  my $h = APR::HTTP::Headers::Compat->new( $table );

Optionally header initialisers may be passed:

  my $h = APR::HTTP::Headers::Compat->new( $table,
    'Content-type' => 'text/plain'
  );

clone

Clone this object. The clone is a regular HTTP::Headers object rather than an APR::HTTP::Headers::Compat.

table

Get the underlying APR::Table object. Changes made in either the table or the wrapper are reflected immediately in the other.

remove_content_headers

This will remove all the header fields used to describe the content of a message. All header field names prefixed with Content- falls into this category, as well as Allow, Expires and Last-Modified. RFC 2616 denote these fields as Entity Header Fields.

The return value is a new HTTP::Headers object that contains the removed headers only. Note that the returned object is not an APR::HTTP::Headers::Compat.

CAVEATS ^

Because the underlying storage for the headers is an APR::Table attempts to store an object (such as a URI instance) in the table will not behave as expected.

I haven't benchmarked but it's certain that this implementation will be substantially slower than HTTP::Headers.

DEPENDENCIES ^

APR::Pool, APR::Table, HTTP::Headers, Storable, Test::More

SEE ALSO ^

FirePHP::Dispatcher

INCOMPATIBILITIES ^

None reported.

BUGS AND LIMITATIONS ^

Please report any bugs or feature requests to bug-apr-http-headers-compat@rt.cpan.org, or through the web interface at http://rt.cpan.org.

AUTHOR ^

Andy Armstrong <andy@hexten.net>

LICENCE AND COPYRIGHT ^

Copyright (c) 2009, Andy Armstrong <andy@hexten.net>.

This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See perlartistic.

syntax highlighting: