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.
24 return bless [ # Defaults
26 'Content-Type' => 'text/html',
27 'X-PLP-Version' => $PLP::VERSION,
30 'content-type' => 'Content-Type',
31 'x-plp-version' => 'X-PLP-Version',
37 my ($self, $key) = @_;
38 return $self->[0]->{ $self->[1]->{_lc $key} };
42 my ($self, $key, $value) = @_;
43 if ($PLP::sentheaders) {
45 die "Can't set headers after sending them at " .
46 "$caller[1] line $caller[2].\n(Output started at " .
47 "$PLP::sentheaders->[0] line $PLP::sentheaders->[1].)\n"
49 if (defined $self->[1]->{_lc $key}){
50 $key = $self->[1]->{_lc $key};
52 $self->[1]->{lc $key} = $key;
54 return ($self->[0]->{$key} = $value);
58 my ($self, $key) = @_;
59 delete $self->[0]->{$key};
60 return delete $self->[1]->{_lc $key};
69 my ($self, $key) = @_;
70 return exists $self->[1]->{_lc $key};
76 return each %{ $self->[0] }; # Key only, Tie::Hash doc is wrong.
80 return each %{ $_[0]->[0] };