| 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | 0 | my $location = $res->header('location'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | 0 | my $status = $res->status; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | 0 | ▶ | if ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/12
$location and $status == 301 || $status == 302 || $status == 303 || $status == 307
$status == 301 or $status == 302 or $status == 303 or $status == 307
$status == 301 or $status == 302 or $status == 303
$status == 301 or $status == 302
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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||