line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Plack::Middleware::AddDefaultCharset; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
840
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
39
|
|
4
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
34
|
|
5
|
1
|
|
|
1
|
|
31
|
use 5.008_001; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
45
|
|
6
|
|
|
|
|
|
|
|
7
|
1
|
|
|
1
|
|
6
|
use parent qw(Plack::Middleware); |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
11
|
|
8
|
1
|
|
|
1
|
|
61
|
use Plack::Util; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
28
|
|
9
|
1
|
|
|
1
|
|
7
|
use Plack::Util::Accessor qw(charset); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
11
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
our $VERSION = '0.02'; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub call { |
14
|
3
|
|
|
3
|
1
|
49823
|
my ($self, $env) = @_; |
15
|
|
|
|
|
|
|
$self->response_cb( |
16
|
|
|
|
|
|
|
$self->app->($env), |
17
|
|
|
|
|
|
|
sub { |
18
|
3
|
|
|
3
|
|
188
|
my $res = shift; |
19
|
3
|
|
|
|
|
5
|
my $headers = $res->[1]; |
20
|
3
|
|
|
|
|
16
|
for (my $i = 0; $i < @$headers; $i += 2) { |
21
|
3
|
50
|
|
|
|
11
|
if (lc($headers->[$i]) eq 'content-type') { |
22
|
3
|
|
|
|
|
5
|
my $cur_type = $headers->[$i + 1]; |
23
|
3
|
100
|
100
|
|
|
25
|
if ($cur_type =~ m{^text/(html|plain)} |
24
|
|
|
|
|
|
|
&& $cur_type !~ /;\s*charset=/) { |
25
|
1
|
|
|
|
|
7
|
$headers->[$i + 1] = |
26
|
|
|
|
|
|
|
"$cur_type; charset=" . $self->charset; |
27
|
|
|
|
|
|
|
} |
28
|
3
|
|
|
|
|
15
|
last; |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
}, |
32
|
3
|
|
|
|
|
21
|
); |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
1; |
36
|
|
|
|
|
|
|
__END__ |