Session/State/Mixin/ResponseFilter.pm

filter: Statementstmt 94.8% 37 / 39 Branchbran 81.8% 18 / 22 Conditioncond 100% 5 / 5 MC/DCmcdc 100% 2 / 2 Subroutinesub 100% 4 / 4 Podpod 0.0% 0 / 1 totaltotal 90.4% 66 / 73 CC 15 SCAR 25.6
CC
15
Cov
91%
response_filter
15.3
BEGIN
1.0
BEGIN
1.0
CRAP 12.9
↑ Summary Session/Store/Memcached.pm »
1 package HTTP::Session::State::Mixin::ResponseFilter;
2 3 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 3 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 3 ▶use Exporter 'import';
Subroutine BEGIN: called CC=1 SCAR=0.0
5 3 our @EXPORT_OK = qw/response_filter/;
6  
7 9 ▶sub response_filter {
Subroutine response_filter: called CC=15 SCAR=27.3
Pod undocumented
8 9 my ($self, $session_id, $res) = @_;
9 9 ▶ Carp::croak "missing session_id" unless $session_id;
Branch: 1 branch
BranchTrueFalseTotal
unless $session_id 1 8 9
10  
11 8 ▶ if (Scalar::Util::blessed $res) {
Branch: 1 branch
BranchTrueFalseTotal
if (builtin::blessed($res)) { } 6 2 8
12 6 ▶ if ($res->code == 302) {
Branch: 2 branches
BranchTrueFalseTotal
if ($res->code == 302) { } 2 4 6
elsif ($res->content and ($res->header('Content-Type') || 'text/html') =~ /html/) { } 2 2 4
13 2 ▶ if (my $uri = $res->header('Location')) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $uri = $res->header("Location")) 1 1 2
14 1 $res->header('Location' => $self->redirect_filter($session_id, $uri));
15 }
16 2 return $res;
17 ▶ } elsif ($res->content && ($res->header('Content-Type')||'text/html') =~ /html/) {
Condition100%5/5
$res->content and ($res->header("Content-Type") || "text/html") =~ /html/
!ll&&!rl&&r
112
$res->header('Content-Type') || 'text/html'
l!l
12
MC/DC100%2/2
$res->content and ($res->header("Content-Type") || "text/html") =~ /html/
$res->content $res->header('Content-Type')
Truth table100%3/3
A and B
A= $res->contentB= $res->header('Content-Type')
ABresult
0X0
100
111
18 2 $res->content( $self->html_filter($session_id, $res->content) );
19 2 return $res;
20 } else {
21 2 return $res; # nop
22 }
23 } else {
24 # psgi
25 2 ▶ if ($res->[0] == 302) {
Branch: 2 branches
BranchTrueFalseTotal
if ($res->[0] == 302) { } 1 1 2
elsif (my $body = $res->[2]) { } 1 0 1
26 1 my @headers = @{ $res->[1] }; # copy
27 1 my @new_headers;
28 1 ▶ while ( my ( $key, $val ) = splice @headers, 0, 2 ) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = splice(@headers, 0, 2)) 1 1 2
29 1 ▶ if (lc($key) eq 'location') {
Branch: 1 branch
BranchTrueFalseTotal
if (lc $key eq "location") 1 0 1
30 1 $val = $self->redirect_filter($session_id, $val);
31 }
32 1 push @new_headers, $key, $val;
33 }
34 1 $res->[1] = \@new_headers;
35 1 return $res;
36 } elsif (my $body = $res->[2]) {
37 1 ▶ if ( ref $body eq 'ARRAY' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $body eq 'ARRAY') { } 1 0 1
38 # TODO: look the content-type header.
39 1 my $content = '';
40 1 for my $line (@$body) {
41 1 ▶ $content .= $line if length $line;
Branch: 1 branch
BranchTrueFalseTotal
if length $line 1 0 1
42 }
43 1 $res->[2] = [$self->html_filter($session_id, $content)];
44 1 return $res;
45 } else { # HTTP::Session should not process glob.
46 0 return $res;
47 }
48 } else {
49 0 return $res; # nop
50 }
51 }
52 }
53  
54 3 1;
↑ Summary Session/Store/Memcached.pm »