1 package PLP::Tie::Headers;
9 =head1 PLP::Tie::Headers
11 Makes a hash case insensitive, and sets some headers. <_> equals <->, so C<$foo{CONTENT_TYPE}> is
12 the same as C<$foo{'Content-Type'}>.
14 tie %somehash, 'PLP::Tie::Headers';
16 This module is part of the PLP internals and probably not of much use to others.
21 return bless [ # Defaults
23 'Content-Type' => 'text/html',
24 'X-PLP-Version' => $PLP::VERSION,
27 'content-type' => 'Content-Type',
28 'x-plp-version' => 'X-PLP-Version',
34 my ($self, $key) = @_;
36 return $self->[0]->{ $self->[1]->{lc $key} };
40 my ($self, $key, $value) = @_;
42 if ($PLP::sentheaders) {
44 die "Can't set headers after sending them at " .
45 "$caller[1] line $caller[2].\n(Output started at " .
46 "$PLP::sentheaders->[0] line $PLP::sentheaders->[1].)\n"
48 if (defined $self->[1]->{lc $key}){
49 $key = $self->[1]->{lc $key};
51 $self->[1]->{lc $key} = $key;
53 return ($self->[0]->{$key} = $value);
57 my ($self, $key) = @_;
59 delete $self->[0]->{$key};
60 return delete $self->[1]->{lc $key};
69 my ($self, $key) = @_;
71 return exists $self->[1]->{lc $key};
77 return each %{ $self->[0] }; # Key only, Tie::Hash doc is wrong.
81 return each %{ $_[0]->[0] };