line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Plack::Middleware::SimpleContentFilter; |
2
|
1
|
|
|
1
|
|
7
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
29
|
|
3
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
26
|
|
4
|
1
|
|
|
1
|
|
5
|
use parent qw( Plack::Middleware ); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
4
|
|
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
52
|
use Plack::Util; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
19
|
|
7
|
1
|
|
|
1
|
|
5
|
use Plack::Util::Accessor qw( filter ); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
8
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
sub call { |
10
|
1
|
|
|
1
|
1
|
10
|
my $self = shift; |
11
|
|
|
|
|
|
|
|
12
|
1
|
|
|
|
|
7
|
my $res = $self->app->(@_); |
13
|
|
|
|
|
|
|
$self->response_cb($res, sub { |
14
|
1
|
|
|
1
|
|
3
|
my $res = shift; |
15
|
1
|
|
|
|
|
4
|
my $h = Plack::Util::headers($res->[1]); |
16
|
1
|
50
|
|
|
|
11
|
return unless $h->get('Content-Type'); |
17
|
1
|
50
|
|
|
|
5
|
if ($h->get('Content-Type') =~ m!^text/!) { |
18
|
|
|
|
|
|
|
return sub { |
19
|
3
|
|
|
|
|
6
|
my $chunk = shift; |
20
|
3
|
100
|
|
|
|
10
|
return unless defined $chunk; |
21
|
2
|
|
|
|
|
6
|
local $_ = $chunk; |
22
|
2
|
|
|
|
|
6
|
$self->filter->(); |
23
|
2
|
|
|
|
|
12
|
return $_; |
24
|
1
|
|
|
|
|
26
|
}; |
25
|
|
|
|
|
|
|
} |
26
|
1
|
|
|
|
|
18
|
}); |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
1; |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
__END__ |