« blib/lib/Plack/Middleware/Auth/Basic.pm
↑ Summary
blib/lib/Plack/Middleware/LighttpdScriptNameFix.pm »
| 1 | package Plack::Middleware::Static; | ||||||||||||||||||||||||||||||||||||||||||
| 2 | 5 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 3 | 5 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 4 | 5 | ▶ | use parent qw/Plack::Middleware/; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 5 | 5 | ▶ | use Plack::App::File; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||||
| 7 | 5 | ▶ | use Plack::Util::Accessor qw( path root encoding pass_through content_type ); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||||||||||||
| 9 | 41 | ▶ | sub call { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
call: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 10 | 41 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 11 | 41 | my $env = shift; | |||||||||||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||||||||||
| 13 | 41 | my $res = $self->_handle_static($env); | |||||||||||||||||||||||||||||||||||||||||
| 14 | 41 | ▶ | if ($res && not ($self->pass_through and $res->[0] == 404)) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition83%5/6
$res and not $self->pass_through && $res->[0] == 404
$self->pass_through && $res->[0] == 404
MC/DC66%2/3
$res and not $self->pass_through && $res->[0] == 404
$res
$self->pass_through
$res->[0] == 404
Truth table75%3/4
A and not(B && C)
A= $resB= $self->pass_throughC= $res->[0] == 404
| |||||||||||||||||||||||||||||||||||||||||||
| 15 | 12 | return $res; | |||||||||||||||||||||||||||||||||||||||||
| 16 | } | ||||||||||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||||||||||
| 18 | 29 | return $self->app->($env); | |||||||||||||||||||||||||||||||||||||||||
| 19 | } | ||||||||||||||||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||||||||||||||||
| 21 | 41 | ▶ | sub _handle_static { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_handle_static: called CC=7 SCAR=19.7
| |||||||||||||||||||||||||||||||||||||||||||
| 22 | 41 | my($self, $env) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||||||||||||||||
| 24 | 41 | ▶ | my $path_match = $self->path or return; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 25 | 41 | my $path = $env->{PATH_INFO}; | |||||||||||||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||||||||||||||
| 27 | 41 | for ($path) { | |||||||||||||||||||||||||||||||||||||||||
| 28 | 41 | ▶ | my $matched = 'CODE' eq ref $path_match ? $path_match->($_, $env) : $_ =~ $path_match; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 29 | 41 | ▶ | return unless $matched; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 30 | } | ||||||||||||||||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||||||||||||||||
| 32 | 13 | ▶ | $self->{file} ||= Plack::App::File->new({ root => $self->root || '.', encoding => $self->encoding, content_type => $self->content_type }); | ||||||||||||||||||||||||||||||||||||||||
|
Condition60%3/5
$self->{"file"} ||= "Plack::App::File"->new({"root", $self->root || ".", "encoding", $self->encoding, "content_type", $self->content_type})
$self->root || '.'
MC/DC0%0/2
$self->{"file"} ||= "Plack::App::File"->new({"root", $self->root || ".", "encoding", $self->encoding, "content_type", $self->content_type})
$self->{"file"}
"Plack::App::File"->new({"root", $self->root || ".", "encoding", $self->encoding, "content_type", $self->content_type})
MC/DC0%0/1
$self->root || '.'
$self->root
Truth table66%2/3
A ||= B
A= $self->{"file"}B= "Plack::App::File"->new({"root", $self->root || ".", "encoding", $self->encoding, "content_type", $self->content_type})
Truth table50%1/2
A
A= $self->root
| |||||||||||||||||||||||||||||||||||||||||||
| 33 | 13 | local $env->{PATH_INFO} = $path; # rewrite PATH | |||||||||||||||||||||||||||||||||||||||||
| 34 | 13 | return $self->{file}->call($env); | |||||||||||||||||||||||||||||||||||||||||
| 35 | } | ||||||||||||||||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||||||||||||||||
| 37 | 5 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 38 | __END__ | ||||||||||||||||||||||||||||||||||||||||||