1 package PLP::Tie::Headers;
7 =head1 PLP::Tie::Headers
9 Makes a hash case insensitive, and sets some headers. <_> equals <->, so C<$foo{CONTENT_TYPE}> is
10 the same as C<$foo{'Content-Type'}>.
12 tie %somehash, 'PLP::Tie::Headers';
14 This module is part of the PLP internals and probably not of much use to others.
19 return bless [ # Defaults
21 'Content-Type' => 'text/html',
22 'X-PLP-Version' => $PLP::VERSION,
25 'content-type' => 'Content-Type',
26 'x-plp-version' => 'X-PLP-Version',
32 my ($self, $key) = @_;
34 return $self->[0]->{ $self->[1]->{lc $key} };
38 my ($self, $key, $value) = @_;
40 if ($PLP::sentheaders) {
42 die "Can't set headers after sending them at " .
43 "$caller[1] line $caller[2].\n(Output started at " .
44 "$PLP::sentheaders->[0] line $PLP::sentheaders->[1].)\n"
46 if (defined $self->[1]->{lc $key}){
47 $key = $self->[1]->{lc $key};
49 $self->[1]->{lc $key} = $key;
51 return ($self->[0]->{$key} = $value);
55 my ($self, $key) = @_;
57 delete $self->[0]->{$key};
58 return delete $self->[1]->{lc $key};
67 my ($self, $key) = @_;
69 return exists $self->[1]->{lc $key};
75 return each %{ $self->[0] }; # Key only, Tie::Hash doc is wrong.
79 return each %{ $_[0]->[0] };