APR-HTTP-Headers-Compat
view release on metacpan or search on metacpan
lib/APR/HTTP/Headers/Compat.pm view on Meta::CPAN
$hdrs->header( 'Content-Type' => 'text/plain' );
=head1 DESCRIPTION
Under mod_perl HTTP headers are stashed in L<APR::Table> objects.
Sometimes you will encounter code (such as L<FirePHP::Dispatcher>) that
needs an L<HTTP::Headers>. This module wraps an C<APR::Table> in a
subclass of C<HTTP::Headers> so that it can be used wherever an
C<HTTP::Headers> is expected.
Synchronisation is bi-directional; changes via the C<HTTP::Headers>
interface are reflected immediately in the underlying C<APR::Table> and
direct changes to the table show up immediately in the wrapper.
=head1 INTERFACE
Unless otherwise stated below all methods are inherited from
C<HTTP::Headers>.
=head2 C<< new >>
Create a new wrapper around an existing C<APR::Table>.
lib/APR/HTTP/Headers/Compat/MagicHash.pm view on Meta::CPAN
sub STORE {
my ( $self, $key, $value ) = @_;
my $nkey = $self->_nicefor( $key );
$self->{rmap}{$nkey} = $key;
my $table = $self->table;
my @vals = 'ARRAY' eq ref $value ? @$value : $value;
$table->set( $nkey, shift @vals );
$table->add( $nkey, $_ ) for @vals;
$self->_changed;
}
sub DELETE {
my ( $self, $key ) = @_;
my $nkey = $self->_nicefor( $key );
my $rv = $self->FETCH( $key );
$self->table->unset( $nkey );
$self->_changed;
return $rv;
}
sub CLEAR {
my ( $self ) = @_;
$self->table->clear;
$self->_changed;
}
sub EXISTS {
my ( $self, $key ) = @_;
my %fld = map { $_ => 1 } $self->_keys;
return exists $fld{$key};
}
sub _mkkeys {
my $self = shift;
lib/APR/HTTP/Headers/Compat/MagicHash.pm view on Meta::CPAN
push @k, $kk unless $seen{$kk}++;
} );
return \@k;
}
sub _keys {
my $self = shift;
return @{ $self->{keys} ||= $self->_mkkeys };
}
sub _changed {
my $self = shift;
delete $self->{keys};
}
sub FIRSTKEY {
my ( $self ) = @_;
$self->{pos} = 0;
return ( $self->_keys )[0];
}
( run in 0.752 second using v1.01-cache-2.11-cpan-5dc5da66d9d )