APR::HTTP::Headers::Compat - Make an APR::Table look like an HTTP::Headers
This document describes APR::HTTP::Headers::Compat version 0.02
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' );
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.
Unless otherwise stated below all methods are inherited from
Create a new wrapper around an existing
# 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 this object. The clone is a regular HTTP::Headers object rather than an
Get the underlying APR::Table object. Changes made in either the table or the wrapper are reflected immediately in the other.
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
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
Please report any bugs or feature requests to
firstname.lastname@example.org, or through the web interface at http://rt.cpan.org.
Copyright (c) 2009, Andy Armstrong
This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See perlartistic.