1 package PLP::Tie::Headers;
6 =head1 PLP::Tie::Headers
8 Makes a hash case insensitive, and sets some headers. <_> equals <->, so C<$foo{CONTENT_TYPE}> is
9 the same as C<$foo{'Content-Type'}>.
11 tie %somehash, 'PLP::Tie::Headers';
13 This module is part of the PLP internals and probably not of much use to others.
18 return bless [ # Defaults
20 'Content-Type' => 'text/html',
21 'X-PLP-Version' => $PLP::VERSION,
24 'content-type' => 'Content-Type',
25 'x-plp-version' => 'X-PLP-Version',
31 my ($self, $key) = @_;
33 return $self->[0]->{ $self->[1]->{lc $key} };
37 my ($self, $key, $value) = @_;
39 if ($PLP::sentheaders) {
41 die "Can't set headers after sending them at " .
42 "$caller[1] line $caller[2].\n(Output started at " .
43 "$PLP::sentheaders->[0] line $PLP::sentheaders->[1].)\n"
45 if (defined $self->[1]->{lc $key}){
46 $key = $self->[1]->{lc $key};
48 $self->[1]->{lc $key} = $key;
50 return ($self->[0]->{$key} = $value);
54 my ($self, $key) = @_;
56 delete $self->[0]->{$key};
57 return delete $self->[1]->{lc $key};
66 my ($self, $key) = @_;
68 return exists $self->[1]->{lc $key};
74 return each %{ $self->[0] }; # Key only, Tie::Hash doc is wrong.
78 return each %{ $_[0]->[0] };