| 1 | package Plack::Middleware::SimpleContentFilter; | ||||||||||
| 2 | 1 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 3 | 1 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 1 | ▶ | use parent qw( Plack::Middleware ); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | |||||||||||
| 6 | 1 | ▶ | use Plack::Util; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | 1 | ▶ | use Plack::Util::Accessor qw( filter ); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 8 | |||||||||||
| 9 | 1 | ▶ | sub call { | ||||||||
|
Subroutine
call: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 10 | 1 | my $self = shift; | |||||||||
| 11 | |||||||||||
| 12 | 1 | my $res = $self->app->(@_); | |||||||||
| 13 | 1 | ▶ | $self->response_cb($res, sub { | ||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=11.0
| |||||||||||
| 14 | 1 | my $res = shift; | |||||||||
| 15 | 1 | my $h = Plack::Util::headers($res->[1]); | |||||||||
| 16 | 1 | ▶ | return unless $h->get('Content-Type'); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 17 | 1 | ▶ | if ($h->get('Content-Type') =~ m!^text/!) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 18 | 3 | ▶ | return sub { | ||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
| |||||||||||
| 19 | 3 | my $chunk = shift; | |||||||||
| 20 | 3 | ▶ | return unless defined $chunk; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 21 | 2 | local $_ = $chunk; | |||||||||
| 22 | 2 | $self->filter->(); | |||||||||
| 23 | 2 | return $_; | |||||||||
| 24 | 1 | }; | |||||||||
| 25 | } | ||||||||||
| 26 | 1 | }); | |||||||||
| 27 | } | ||||||||||
| 28 | |||||||||||
| 29 | 1 | 1; | |||||||||
| 30 | |||||||||||
| 31 | __END__ | ||||||||||