Spore/Middleware/Redirection.pm

filter: Statementstmt 32.0% 8 / 25 Branchbran 0.0% 0 / 4 Conditioncond 0.0% 0 / 12 MC/DCmcdc 0.0% 0 / 5 Subroutinesub 33.3% 1 / 3 Podpod 0.0% 0 / 1 totaltotal 18.0% 9 / 50 CC 7 SCAR 37.8
CC
7
Cov
20%
__ANON__
56.0
call
2.0
BEGIN
1.0
CRAP 43.9
↑ Summary Spore/Middleware/Auth/ApiKey.pm »
1 package Net::HTTP::Spore::Middleware::Redirection;
2 1 $Net::HTTP::Spore::Middleware::Redirection::VERSION = '0.09';
3 # ABSTRACT: Middleware for redirections
4  
5 1 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 1 extends 'Net::HTTP::Spore::Middleware';
8  
9 1 with 'Net::HTTP::Spore::Role::Request', 'Net::HTTP::Spore::Role::UserAgent';
10  
11 1 has max_redirect => ( is => 'rw', isa => 'Int', lazy => 1, default => 5 );
12  
13 0 ▶sub call {
Subroutine call: not called CC=1 SCAR=6.9
Pod undocumented
14 0 my ( $self, $req ) = @_;
15  
16 0 my $nredirect = 0;
17  
18 return $self->response_cb(
19 0 ▶ sub {
Subroutine __ANON__: not called CC=7 SCAR=40.3
20 0 my $res = shift;
21 0 ▶ while ( $nredirect < $self->max_redirect ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($nredirect < $self->max_redirect) 0 0 0
22 0 my $location = $res->header('location');
23 0 my $status = $res->status;
24 0 ▶ if (
Branch: 1 branch
BranchTrueFalseTotal
if ($location and $status == 301 || $status == 302 || $status == 303 || $status == 307) { } 0 0 0
Condition0%0/12
$location and $status == 301 || $status == 302 || $status == 303 || $status == 307
!ll&&!rl&&r
000
$status == 301 or $status == 302 or $status == 303 or $status == 307
l!l&&r!l&&!r
000
$status == 301 or $status == 302 or $status == 303
l!l&&r!l&&!r
000
$status == 301 or $status == 302
l!l&&r!l&&!r
000
MC/DC0%0/5
$location and $status == 301 || $status == 302 || $status == 303 || $status == 307
$location $status == 301 $status == 302 $status == 303 $status == 307
Truth table0%0/6
A and B or C or D or E
A= $locationB= $status == 301C= $status == 302D= $status == 303E= $status == 307
ABCDEresult
0XXXX0
100000
11XXX1
101XX1
1001X1
100011
25 $location
26 and ( $status == 301
27 or $status == 302
28 or $status == 303
29 or $status == 307 )
30 )
31 {
32 0 my $uri = URI->new($location);
33 0 $req->env->{HTTP_HOST} = $uri->host;
34 0 $req->env->{PATH_INFO} = $uri->path;
35 0 $req->env->{SERVER_PORT} = $uri->port;
36 0 $req->env->{SERVER_NAME} = $uri->host;
37 0 $res = $self->_request($req);
38 0 $nredirect++;
39 }else{
40 0 last;
41 }
42 }
43 0 return $res;
44 }
45 0 );
46 }
47  
48 1 1;
49  
50 __END__
↑ Summary Spore/Middleware/Auth/ApiKey.pm »