1 #----------------------------#
2 package PLP::Tie::Headers;
3 #----------------------------#
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.
25 return bless [ # Defaults.
27 'Content-Type' => 'text/html',
28 'X-PLP-Version' => $PLP::VERSION,
31 'content-type' => 'Content-Type',
32 'x-plp-version' => 'X-PLP-Version',
38 my ($self, $key) = @_;
39 return $self->[0]->{ $self->[1]->{_lc $key} };
43 my ($self, $key, $value) = @_;
44 croak 'Can\'t set headers after sending them!' if $PLP::sentheaders;
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) = @_;
55 delete $self->[0]->{$key};
56 return delete $self->[1]->{_lc $key};
65 my ($self, $key) = @_;
66 return exists $self->[1]->{_lc $key};
72 return each %{ $self->[0] }; # Key only, Tie::Hash doc is wrong.
76 return each %{ $_[0]->[0] };