git.shiar.nl
/
perl
/
plp
/
.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
vim: drop vim v5.x compatibility
[perl/plp/.git]
/
lib
/
PLP
/
Tie
/
Headers.pm
diff --git
a/lib/PLP/Tie/Headers.pm
b/lib/PLP/Tie/Headers.pm
index c675f8a128d7f8420caeb00ab6b296117bef71cb..f0db9685db327b70ddbdf2ef9af4642a4a442277 100644
(file)
--- a/
lib/PLP/Tie/Headers.pm
+++ b/
lib/PLP/Tie/Headers.pm
@@
-4,7
+4,7
@@
use strict;
use warnings;
use Carp;
use warnings;
use Carp;
-our $VERSION = '1.0
0
';
+our $VERSION = '1.0
1
';
=head1 PLP::Tie::Headers
=head1 PLP::Tie::Headers
@@
-26,14
+26,21
@@
sub TIEHASH {
{
'content-type' => 'Content-Type',
'x-plp-version' => 'X-PLP-Version',
{
'content-type' => 'Content-Type',
'x-plp-version' => 'X-PLP-Version',
- }
+ },
+ 1 # = content-type untouched
], $_[0];
}
sub FETCH {
my ($self, $key) = @_;
], $_[0];
}
sub FETCH {
my ($self, $key) = @_;
+ if ($self->[2] and defined $self->[0]->{'Content-Type'}) {
+ my $utf8 = eval { grep {$_ eq "utf8"} PerlIO::get_layers(*STDOUT) };
+ $self->[0]->{'Content-Type'} .= '; charset=utf-8' if $utf8;
+ $self->[2] = 0;
+ }
$key =~ tr/_/-/;
$key =~ tr/_/-/;
- return $self->[0]->{ $self->[1]->{lc $key} };
+ defined ($key = $self->[1]->{lc $key}) or return;
+ return $self->[0]->{$key};
}
sub STORE {
}
sub STORE {
@@
-50,14
+57,15
@@
sub STORE {
} else {
$self->[1]->{lc $key} = $key;
}
} else {
$self->[1]->{lc $key} = $key;
}
+ $self->[2] = 0 if $key eq 'Content-Type';
return ($self->[0]->{$key} = $value);
}
sub DELETE {
my ($self, $key) = @_;
$key =~ tr/_/-/;
return ($self->[0]->{$key} = $value);
}
sub DELETE {
my ($self, $key) = @_;
$key =~ tr/_/-/;
- de
lete $self->[0]->{$key}
;
- return delete $self->[
1]->{lc
$key};
+ de
fined ($key = delete $self->[1]->{lc $key}) or return
;
+ return delete $self->[
0]->{
$key};
}
sub CLEAR {
}
sub CLEAR {