| 1 | package Plack::Util; | ||||||||||||||||||||||||||||||||||||||||||
| 2 | 155 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 3 | 155 | ▶ | use Carp (); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 4 | 155 | ▶ | use Scalar::Util; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 5 | 155 | ▶ | use IO::Handle; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 6 | 155 | ▶ | use overload (); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 7 | 155 | ▶ | use File::Spec (); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||||||||||||
| 9 | sub TRUE() { 1==1 } | ||||||||||||||||||||||||||||||||||||||||||
| 10 | sub FALSE() { !TRUE } | ||||||||||||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||||||||||||
| 12 | # there does not seem to be a relevant RT or perldelta entry for this | ||||||||||||||||||||||||||||||||||||||||||
| 13 | 155 | ▶ | use constant _SPLICE_SAME_ARRAY_SEGFAULT => $] < '5.008007'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||||||||||||
| 15 | 112 | ▶ | sub load_class { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
load_class: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 16 | 112 | my($class, $prefix) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||||||||||
| 18 | 112 | ▶ | if ($prefix) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 19 | 111 | ▶ | unless ($class =~ s/^\+// || $class =~ /^$prefix/) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$class =~ s/^\+// or $class =~ /^$prefix/
MC/DC50%1/2
$class =~ s/^\+// or $class =~ /^$prefix/
$class =~ s/^\+//
$class =~ /^$prefix/
Truth table66%2/3
A or B
A= $class =~ s/^\+//B= $class =~ /^$prefix/
| |||||||||||||||||||||||||||||||||||||||||||
| 20 | 64 | $class = "$prefix\::$class"; | |||||||||||||||||||||||||||||||||||||||||
| 21 | } | ||||||||||||||||||||||||||||||||||||||||||
| 22 | } | ||||||||||||||||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||||||||||||||||
| 24 | 112 | my $file = $class; | |||||||||||||||||||||||||||||||||||||||||
| 25 | 112 | $file =~ s!::!/!g; | |||||||||||||||||||||||||||||||||||||||||
| 26 | 112 | require "$file.pm"; ## no critic | |||||||||||||||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||||||||||||||||
| 28 | 111 | return $class; | |||||||||||||||||||||||||||||||||||||||||
| 29 | } | ||||||||||||||||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||||||||||||||||
| 31 | 14 | ▶ | sub is_real_fh ($) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_real_fh: called CC=12 SCAR=25.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 32 | 14 | my $fh = shift; | |||||||||||||||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||||||||||||||||
| 34 | { | ||||||||||||||||||||||||||||||||||||||||||
| 35 | 155 | ▶ | no warnings 'uninitialized'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 36 | 14 | ▶ | return FALSE if -p $fh or -c _ or -b _; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%4/6
-p $fh or -c _ or -b _
-p $fh or -c _
MC/DC33%1/3
-p $fh or -c _ or -b _
-p $fh
-c _
-b _
Truth table50%2/4
A or B or C
A= -p $fhB= -c _C= -b _
| |||||||||||||||||||||||||||||||||||||||||||
| 37 | } | ||||||||||||||||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||||||||||||||||
| 39 | 12 | ▶ | my $reftype = Scalar::Util::reftype($fh) or return; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 40 | 10 | ▶ | if ( $reftype eq 'IO' | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition80%4/5
$reftype eq "IO" or $reftype eq "GLOB" and *{$fh;}{"IO"}
$reftype eq "GLOB" and *{$fh;}{"IO"}
MC/DC50%1/2
$reftype eq "IO" or $reftype eq "GLOB" and *{$fh;}{"IO"}
$reftype eq "IO"
$reftype eq "GLOB"
Truth table66%2/3
A or B
A= $reftype eq "IO"B= $reftype eq "GLOB"
| |||||||||||||||||||||||||||||||||||||||||||
| 41 | 8 | or $reftype eq 'GLOB' && *{$fh}{IO} | |||||||||||||||||||||||||||||||||||||||||
| 42 | ) { | ||||||||||||||||||||||||||||||||||||||||||
| 43 | # if it's a blessed glob make sure to not break encapsulation with | ||||||||||||||||||||||||||||||||||||||||||
| 44 | # fileno($fh) (e.g. if you are filtering output then file descriptor | ||||||||||||||||||||||||||||||||||||||||||
| 45 | # based operations might no longer be valid). | ||||||||||||||||||||||||||||||||||||||||||
| 46 | # then ensure that the fileno *opcode* agrees too, that there is a | ||||||||||||||||||||||||||||||||||||||||||
| 47 | # valid IO object inside $fh either directly or indirectly and that it | ||||||||||||||||||||||||||||||||||||||||||
| 48 | # corresponds to a real file descriptor. | ||||||||||||||||||||||||||||||||||||||||||
| 49 | 8 | my $m_fileno = $fh->fileno; | |||||||||||||||||||||||||||||||||||||||||
| 50 | 8 | ▶ | return FALSE unless defined $m_fileno; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 51 | 8 | ▶ | return FALSE unless $m_fileno >= 0; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||||||||||||||||
| 53 | 5 | my $f_fileno = fileno($fh); | |||||||||||||||||||||||||||||||||||||||||
| 54 | 5 | ▶ | return FALSE unless defined $f_fileno; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 55 | 5 | ▶ | return FALSE unless $f_fileno >= 0; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 56 | 5 | return TRUE; | |||||||||||||||||||||||||||||||||||||||||
| 57 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 58 | # anything else, including GLOBS without IO (even if they are blessed) | ||||||||||||||||||||||||||||||||||||||||||
| 59 | # and non GLOB objects that look like filehandle objects cannot have a | ||||||||||||||||||||||||||||||||||||||||||
| 60 | # valid file descriptor in fileno($fh) context so may break. | ||||||||||||||||||||||||||||||||||||||||||
| 61 | 2 | return FALSE; | |||||||||||||||||||||||||||||||||||||||||
| 62 | } | ||||||||||||||||||||||||||||||||||||||||||
| 63 | } | ||||||||||||||||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||||||||||||||||
| 65 | 20 | ▶ | sub set_io_path { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
set_io_path: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 66 | 20 | my($fh, $path) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 67 | 20 | bless $fh, 'Plack::Util::IOWithPath'; | |||||||||||||||||||||||||||||||||||||||||
| 68 | 20 | $fh->path($path); | |||||||||||||||||||||||||||||||||||||||||
| 69 | } | ||||||||||||||||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||||||||||||||||
| 71 | 599 | ▶ | sub content_length { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
content_length: called CC=5 SCAR=16.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 72 | 599 | my $body = shift; | |||||||||||||||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||||||||||||||||
| 74 | 599 | ▶ | return unless defined $body; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||||||||||||||||
| 76 | 599 | ▶ | if (ref $body eq 'ARRAY') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 77 | 595 | my $cl = 0; | |||||||||||||||||||||||||||||||||||||||||
| 78 | 595 | for my $chunk (@$body) { | |||||||||||||||||||||||||||||||||||||||||
| 79 | 664 | $cl += length $chunk; | |||||||||||||||||||||||||||||||||||||||||
| 80 | } | ||||||||||||||||||||||||||||||||||||||||||
| 81 | 595 | return $cl; | |||||||||||||||||||||||||||||||||||||||||
| 82 | } elsif ( is_real_fh($body) ) { | ||||||||||||||||||||||||||||||||||||||||||
| 83 | 3 | return (-s $body) - tell($body); | |||||||||||||||||||||||||||||||||||||||||
| 84 | } | ||||||||||||||||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||||||||||||||||
| 86 | 1 | return; | |||||||||||||||||||||||||||||||||||||||||
| 87 | } | ||||||||||||||||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||||||||||||||||
| 89 | 736 | ▶ | sub foreach { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
foreach: called CC=7 SCAR=19.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 90 | 736 | my($body, $cb) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||||||||||||||||
| 92 | 736 | ▶ | if (ref $body eq 'ARRAY') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 93 | 724 | for my $line (@$body) { | |||||||||||||||||||||||||||||||||||||||||
| 94 | 781 | ▶ | $cb->($line) if length $line; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 95 | } | ||||||||||||||||||||||||||||||||||||||||||
| 96 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 97 | 12 | ▶ | local $/ = \65536 unless ref $/; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 98 | 12 | ▶ | while (defined(my $line = $body->getline)) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 99 | 10 | ▶ | $cb->($line) if length $line; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 100 | } | ||||||||||||||||||||||||||||||||||||||||||
| 101 | 6 | $body->close; | |||||||||||||||||||||||||||||||||||||||||
| 102 | } | ||||||||||||||||||||||||||||||||||||||||||
| 103 | } | ||||||||||||||||||||||||||||||||||||||||||
| 104 | |||||||||||||||||||||||||||||||||||||||||||
| 105 | 1 | ▶ | sub class_to_file { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
class_to_file: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 106 | 1 | my $class = shift; | |||||||||||||||||||||||||||||||||||||||||
| 107 | 1 | $class =~ s!::!/!g; | |||||||||||||||||||||||||||||||||||||||||
| 108 | 1 | $class . ".pm"; | |||||||||||||||||||||||||||||||||||||||||
| 109 | } | ||||||||||||||||||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||||||||||||||||
| 111 | 9 | ▶ | sub _load_sandbox { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_load_sandbox: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 112 | 9 | my $_file = shift; | |||||||||||||||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||||||||||||||||
| 114 | 9 | my $_package = $_file; | |||||||||||||||||||||||||||||||||||||||||
| 115 | 9 | $_package =~ s/([^A-Za-z0-9_])/sprintf("_%2x", unpack("C", $1))/eg; | |||||||||||||||||||||||||||||||||||||||||
| 116 | |||||||||||||||||||||||||||||||||||||||||||
| 117 | 9 | local $0 = $_file; # so FindBin etc. works | |||||||||||||||||||||||||||||||||||||||||
| 118 | 9 | local @ARGV = (); # Some frameworks might try to parse @ARGV | |||||||||||||||||||||||||||||||||||||||||
| 119 | |||||||||||||||||||||||||||||||||||||||||||
| 120 | 9 | return eval sprintf <<'END_EVAL', $_package; | |||||||||||||||||||||||||||||||||||||||||
| 121 | package Plack::Sandbox::%s; | ||||||||||||||||||||||||||||||||||||||||||
| 122 | { | ||||||||||||||||||||||||||||||||||||||||||
| 123 | my $app = do $_file; | ||||||||||||||||||||||||||||||||||||||||||
| 124 | if ( !$app && ( my $error = $@ || $! )) { die $error; } | ||||||||||||||||||||||||||||||||||||||||||
| 125 | $app; | ||||||||||||||||||||||||||||||||||||||||||
| 126 | } | ||||||||||||||||||||||||||||||||||||||||||
| 127 | END_EVAL | ||||||||||||||||||||||||||||||||||||||||||
| 128 | } | ||||||||||||||||||||||||||||||||||||||||||
| 129 | |||||||||||||||||||||||||||||||||||||||||||
| 130 | 9 | ▶ | sub load_psgi { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
load_psgi: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 131 | 9 | my $stuff = shift; | |||||||||||||||||||||||||||||||||||||||||
| 132 | |||||||||||||||||||||||||||||||||||||||||||
| 133 | 9 | ▶ | local $ENV{PLACK_ENV} = $ENV{PLACK_ENV} || 'development'; | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$ENV{'PLACK_ENV'} || 'development'
MC/DC0%0/1
$ENV{'PLACK_ENV'} || 'development'
$ENV{'PLACK_ENV'}
Truth table50%1/2
A
A= $ENV{'PLACK_ENV'}
| |||||||||||||||||||||||||||||||||||||||||||
| 134 | |||||||||||||||||||||||||||||||||||||||||||
| 135 | 9 | ▶ | my $file = $stuff =~ /^[a-zA-Z0-9\_\:]+$/ ? class_to_file($stuff) : File::Spec->rel2abs($stuff); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 136 | 9 | my $app = _load_sandbox($file); | |||||||||||||||||||||||||||||||||||||||||
| 137 | 9 | ▶ | die "Error while loading $file: $@" if $@; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 138 | |||||||||||||||||||||||||||||||||||||||||||
| 139 | 7 | return $app; | |||||||||||||||||||||||||||||||||||||||||
| 140 | } | ||||||||||||||||||||||||||||||||||||||||||
| 141 | |||||||||||||||||||||||||||||||||||||||||||
| 142 | 748 | ▶ | sub run_app($$) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
run_app: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 143 | 748 | my($app, $env) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 144 | |||||||||||||||||||||||||||||||||||||||||||
| 145 | 748 | ▶ | return eval { $app->($env) } || do { | ||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
eval {
do {
&$app($env)
}
} || do {
my $body = 'Internal Server Error';
$env->{'psgi.errors'}->print($@);
[500, ['Content-Type', 'text/plain', 'Content-Length', length $body], [$body]]
}
MC/DC0%0/2
eval {
do {
&$app($env)
}
} || do {
my $body = 'Internal Server Error';
$env->{'psgi.errors'}->print($@);
[500, ['Content-Type', 'text/plain', 'Content-Length', length $body], [$body]]
}
eval {
do {
&$app($env)
}
}
do {
my $body = 'Internal Server Error';
$env->{'psgi.errors'}->print($@);
[500, ['Content-Type', 'text/plain', 'Content-Length', length $body], [$body]]
}
Truth table66%2/3
A || B
A= eval {
do {
&$app($env)
}
}B= do {
my $body = 'Internal Server Error';
$env->{'psgi.errors'}->print($@);
[500, ['Content-Type', 'text/plain', 'Content-Length', length $body], [$body]]
}
| |||||||||||||||||||||||||||||||||||||||||||
| 146 | 1 | my $body = "Internal Server Error"; | |||||||||||||||||||||||||||||||||||||||||
| 147 | 1 | $env->{'psgi.errors'}->print($@); | |||||||||||||||||||||||||||||||||||||||||
| 148 | 1 | [ 500, [ 'Content-Type' => 'text/plain', 'Content-Length' => length($body) ], [ $body ] ]; | |||||||||||||||||||||||||||||||||||||||||
| 149 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 150 | } | ||||||||||||||||||||||||||||||||||||||||||
| 151 | |||||||||||||||||||||||||||||||||||||||||||
| 152 | 691 | ▶ | sub headers { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
headers: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 153 | 691 | my $headers = shift; | |||||||||||||||||||||||||||||||||||||||||
| 154 | inline_object( | ||||||||||||||||||||||||||||||||||||||||||
| 155 | 0 | ▶ | iter => sub { header_iter($headers, @_) }, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 156 | 21 | ▶ | get => sub { header_get($headers, @_) }, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 157 | 9 | ▶ | set => sub { header_set($headers, @_) }, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 158 | 587 | ▶ | push => sub { header_push($headers, @_) }, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 159 | 1268 | ▶ | exists => sub { header_exists($headers, @_) }, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 160 | 22 | ▶ | remove => sub { header_remove($headers, @_) }, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 161 | 2 | ▶ | headers => sub { $headers }, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 162 | 691 | ); | |||||||||||||||||||||||||||||||||||||||||
| 163 | } | ||||||||||||||||||||||||||||||||||||||||||
| 164 | |||||||||||||||||||||||||||||||||||||||||||
| 165 | 689 | ▶ | sub header_iter { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
header_iter: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 166 | 689 | my($headers, $code) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 167 | |||||||||||||||||||||||||||||||||||||||||||
| 168 | 689 | my @headers = @$headers; # copy | |||||||||||||||||||||||||||||||||||||||||
| 169 | 689 | ▶ | while (my($key, $val) = splice @headers, 0, 2) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 170 | 1510 | $code->($key, $val); | |||||||||||||||||||||||||||||||||||||||||
| 171 | } | ||||||||||||||||||||||||||||||||||||||||||
| 172 | } | ||||||||||||||||||||||||||||||||||||||||||
| 173 | |||||||||||||||||||||||||||||||||||||||||||
| 174 | 26 | ▶ | sub header_get { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
header_get: called CC=7 SCAR=19.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 175 | 26 | my($headers, $key) = (shift, lc shift); | |||||||||||||||||||||||||||||||||||||||||
| 176 | |||||||||||||||||||||||||||||||||||||||||||
| 177 | 26 | ▶ | return () if not @$headers; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 178 | |||||||||||||||||||||||||||||||||||||||||||
| 179 | 24 | my $i = 0; | |||||||||||||||||||||||||||||||||||||||||
| 180 | |||||||||||||||||||||||||||||||||||||||||||
| 181 | 24 | ▶ | if (wantarray) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 182 | return map { | ||||||||||||||||||||||||||||||||||||||||||
| 183 | 2 | ▶ | $key eq lc $headers->[$i++] ? $headers->[$i++] : ++$i && (); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
++$i and ()
MC/DC0%0/2
++$i and ()
++$i
()
Truth table33%1/3
A and B
A= ++$iB= ()
| |||||||||||||||||||||||||||||||||||||||||||
| 184 | } 1 .. @$headers/2; | ||||||||||||||||||||||||||||||||||||||||||
| 185 | } | ||||||||||||||||||||||||||||||||||||||||||
| 186 | |||||||||||||||||||||||||||||||||||||||||||
| 187 | 22 | ▶ | while ($i < @$headers) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 188 | 27 | ▶ | return $headers->[$i+1] if $key eq lc $headers->[$i]; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 189 | 5 | $i += 2; | |||||||||||||||||||||||||||||||||||||||||
| 190 | } | ||||||||||||||||||||||||||||||||||||||||||
| 191 | |||||||||||||||||||||||||||||||||||||||||||
| 192 | 0 | (); | |||||||||||||||||||||||||||||||||||||||||
| 193 | } | ||||||||||||||||||||||||||||||||||||||||||
| 194 | |||||||||||||||||||||||||||||||||||||||||||
| 195 | 30 | ▶ | sub header_set { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
header_set: called CC=8 SCAR=20.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 196 | 30 | my($headers, $key, $val) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 197 | |||||||||||||||||||||||||||||||||||||||||||
| 198 | 30 | ▶ | @$headers = ($key, $val), return if not @$headers; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 199 | |||||||||||||||||||||||||||||||||||||||||||
| 200 | 28 | my ($i, $_key) = (0, lc $key); | |||||||||||||||||||||||||||||||||||||||||
| 201 | |||||||||||||||||||||||||||||||||||||||||||
| 202 | # locate and change existing header | ||||||||||||||||||||||||||||||||||||||||||
| 203 | 28 | ▶ | while ($i < @$headers) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 204 | 35 | ▶ | $headers->[$i+1] = $val, last if $_key eq lc $headers->[$i]; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 205 | 27 | $i += 2; | |||||||||||||||||||||||||||||||||||||||||
| 206 | } | ||||||||||||||||||||||||||||||||||||||||||
| 207 | |||||||||||||||||||||||||||||||||||||||||||
| 208 | 28 | ▶ | if ($i > $#$headers) { # didn't find it? | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 209 | 20 | push @$headers, $key, $val; | |||||||||||||||||||||||||||||||||||||||||
| 210 | 20 | return; | |||||||||||||||||||||||||||||||||||||||||
| 211 | } | ||||||||||||||||||||||||||||||||||||||||||
| 212 | |||||||||||||||||||||||||||||||||||||||||||
| 213 | 8 | $i += 2; # found and changed it; so, first, skip that pair | |||||||||||||||||||||||||||||||||||||||||
| 214 | |||||||||||||||||||||||||||||||||||||||||||
| 215 | 8 | ▶ | return if $i > $#$headers; # anything left? | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 216 | |||||||||||||||||||||||||||||||||||||||||||
| 217 | # yes... so do the same thing as header_remove | ||||||||||||||||||||||||||||||||||||||||||
| 218 | # but for the tail of the array only, starting at $i | ||||||||||||||||||||||||||||||||||||||||||
| 219 | |||||||||||||||||||||||||||||||||||||||||||
| 220 | 4 | my $keep; | |||||||||||||||||||||||||||||||||||||||||
| 221 | my @keep = grep { | ||||||||||||||||||||||||||||||||||||||||||
| 222 | 4 | ▶ | $_ & 1 ? $keep : ($keep = $_key ne lc $headers->[$_]); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 223 | } $i .. $#$headers; | ||||||||||||||||||||||||||||||||||||||||||
| 224 | |||||||||||||||||||||||||||||||||||||||||||
| 225 | 4 | my $remainder = @$headers - $i; | |||||||||||||||||||||||||||||||||||||||||
| 226 | 4 | ▶ | return if @keep == $remainder; # if we're not changing anything... | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 227 | |||||||||||||||||||||||||||||||||||||||||||
| 228 | splice @$headers, $i, $remainder, ( _SPLICE_SAME_ARRAY_SEGFAULT | ||||||||||||||||||||||||||||||||||||||||||
| 229 | 1 | ? @{[ @$headers[@keep] ]} # force different source array | |||||||||||||||||||||||||||||||||||||||||
| 230 | : @$headers[@keep] | ||||||||||||||||||||||||||||||||||||||||||
| 231 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 232 | 1 | (); | |||||||||||||||||||||||||||||||||||||||||
| 233 | } | ||||||||||||||||||||||||||||||||||||||||||
| 234 | |||||||||||||||||||||||||||||||||||||||||||
| 235 | 590 | ▶ | sub header_push { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
header_push: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 236 | 590 | my($headers, $key, $val) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 237 | 590 | push @$headers, $key, $val; | |||||||||||||||||||||||||||||||||||||||||
| 238 | } | ||||||||||||||||||||||||||||||||||||||||||
| 239 | |||||||||||||||||||||||||||||||||||||||||||
| 240 | 1275 | ▶ | sub header_exists { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
header_exists: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 241 | 1275 | my($headers, $key) = (shift, lc shift); | |||||||||||||||||||||||||||||||||||||||||
| 242 | |||||||||||||||||||||||||||||||||||||||||||
| 243 | 1275 | my $check; | |||||||||||||||||||||||||||||||||||||||||
| 244 | 1275 | for (@$headers) { | |||||||||||||||||||||||||||||||||||||||||
| 245 | 3363 | ▶ | return 1 if ($check = not $check) and $key eq lc; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$check = !$check and $key eq lc $_
MC/DC100%2/2
$check = !$check and $key eq lc $_
$check = !$check
$key eq lc $_
Truth table100%3/3
not(A) and B
A= $check = !$checkB= $key eq lc $_
| |||||||||||||||||||||||||||||||||||||||||||
| 246 | } | ||||||||||||||||||||||||||||||||||||||||||
| 247 | |||||||||||||||||||||||||||||||||||||||||||
| 248 | 1186 | return !1; | |||||||||||||||||||||||||||||||||||||||||
| 249 | } | ||||||||||||||||||||||||||||||||||||||||||
| 250 | |||||||||||||||||||||||||||||||||||||||||||
| 251 | 40 | ▶ | sub header_remove { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
header_remove: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 252 | 40 | my($headers, $key) = (shift, lc shift); | |||||||||||||||||||||||||||||||||||||||||
| 253 | |||||||||||||||||||||||||||||||||||||||||||
| 254 | 40 | ▶ | return if not @$headers; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 255 | |||||||||||||||||||||||||||||||||||||||||||
| 256 | 39 | my $keep; | |||||||||||||||||||||||||||||||||||||||||
| 257 | my @keep = grep { | ||||||||||||||||||||||||||||||||||||||||||
| 258 | 39 | ▶ | $_ & 1 ? $keep : ($keep = $key ne lc $headers->[$_]); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 259 | } 0 .. $#$headers; | ||||||||||||||||||||||||||||||||||||||||||
| 260 | |||||||||||||||||||||||||||||||||||||||||||
| 261 | 39 | ▶ | @$headers = @$headers[@keep] if @keep < @$headers; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 262 | 39 | (); | |||||||||||||||||||||||||||||||||||||||||
| 263 | } | ||||||||||||||||||||||||||||||||||||||||||
| 264 | |||||||||||||||||||||||||||||||||||||||||||
| 265 | 672 | ▶ | sub status_with_no_entity_body { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
status_with_no_entity_body: called CC=3 SCAR=12.5
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 266 | 672 | my $status = shift; | |||||||||||||||||||||||||||||||||||||||||
| 267 | 672 | ▶ | return $status < 200 || $status == 204 || $status == 304; | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%3/6
$status < 200 || $status == 204 || $status == 304
$status < 200 or $status == 204
MC/DC33%1/3
$status < 200 || $status == 204 || $status == 304
$status < 200
$status == 204
$status == 304
Truth table50%2/4
A or B || C
A= $status < 200B= $status == 204C= $status == 304
| |||||||||||||||||||||||||||||||||||||||||||
| 268 | } | ||||||||||||||||||||||||||||||||||||||||||
| 269 | |||||||||||||||||||||||||||||||||||||||||||
| 270 | 42 | ▶ | sub encode_html { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
encode_html: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 271 | 42 | my $str = shift; | |||||||||||||||||||||||||||||||||||||||||
| 272 | 42 | $str =~ s/&/&/g; | |||||||||||||||||||||||||||||||||||||||||
| 273 | 42 | $str =~ s/>/>/g; | |||||||||||||||||||||||||||||||||||||||||
| 274 | 42 | $str =~ s/</</g; | |||||||||||||||||||||||||||||||||||||||||
| 275 | 42 | $str =~ s/"/"/g; | |||||||||||||||||||||||||||||||||||||||||
| 276 | 42 | $str =~ s/'/'/g; | |||||||||||||||||||||||||||||||||||||||||
| 277 | 42 | return $str; | |||||||||||||||||||||||||||||||||||||||||
| 278 | } | ||||||||||||||||||||||||||||||||||||||||||
| 279 | |||||||||||||||||||||||||||||||||||||||||||
| 280 | 733 | ▶ | sub inline_object { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
inline_object: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 281 | 733 | my %args = @_; | |||||||||||||||||||||||||||||||||||||||||
| 282 | 733 | bless \%args, 'Plack::Util::Prototype'; | |||||||||||||||||||||||||||||||||||||||||
| 283 | } | ||||||||||||||||||||||||||||||||||||||||||
| 284 | |||||||||||||||||||||||||||||||||||||||||||
| 285 | 766 | ▶ | sub response_cb { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
response_cb: called CC=3 SCAR=11.3
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 286 | 766 | my($res, $cb) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 287 | |||||||||||||||||||||||||||||||||||||||||||
| 288 | 766 | ▶ | my $body_filter = sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=7 SCAR=21.2
| |||||||||||||||||||||||||||||||||||||||||||
| 289 | 766 | my($cb, $res) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 290 | 766 | my $filter_cb = $cb->($res); | |||||||||||||||||||||||||||||||||||||||||
| 291 | # If response_cb returns a callback, treat it as a $body filter | ||||||||||||||||||||||||||||||||||||||||||
| 292 | 764 | ▶ | if (defined $filter_cb && ref $filter_cb eq 'CODE') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
defined $filter_cb and ref $filter_cb eq "CODE"
MC/DC100%2/2
defined $filter_cb and ref $filter_cb eq "CODE"
defined $filter_cb
ref $filter_cb eq "CODE"
Truth table100%3/3
A and B
A= defined $filter_cbB= ref $filter_cb eq "CODE"
| |||||||||||||||||||||||||||||||||||||||||||
| 293 | 9 | Plack::Util::header_remove($res->[1], 'Content-Length'); | |||||||||||||||||||||||||||||||||||||||||
| 294 | 9 | ▶ | if (defined $res->[2]) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 295 | 2 | ▶ | if (ref $res->[2] eq 'ARRAY') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 296 | 2 | for my $line (@{$res->[2]}) { | |||||||||||||||||||||||||||||||||||||||||
| 297 | 3 | $line = $filter_cb->($line); | |||||||||||||||||||||||||||||||||||||||||
| 298 | } | ||||||||||||||||||||||||||||||||||||||||||
| 299 | # Send EOF. | ||||||||||||||||||||||||||||||||||||||||||
| 300 | 2 | my $eof = $filter_cb->( undef ); | |||||||||||||||||||||||||||||||||||||||||
| 301 | 0 | ▶ | push @{ $res->[2] }, $eof if defined $eof; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 302 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 303 | 0 | my $body = $res->[2]; | |||||||||||||||||||||||||||||||||||||||||
| 304 | 0 | ▶ | my $getline = sub { $body->getline }; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 305 | $res->[2] = Plack::Util::inline_object | ||||||||||||||||||||||||||||||||||||||||||
| 306 | 0 | ▶ | getline => sub { $filter_cb->($getline->()) }, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 307 | 0 | ▶ | close => sub { $body->close }; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 308 | } | ||||||||||||||||||||||||||||||||||||||||||
| 309 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 310 | 7 | return $filter_cb; | |||||||||||||||||||||||||||||||||||||||||
| 311 | } | ||||||||||||||||||||||||||||||||||||||||||
| 312 | } | ||||||||||||||||||||||||||||||||||||||||||
| 313 | 766 | }; | |||||||||||||||||||||||||||||||||||||||||
| 314 | |||||||||||||||||||||||||||||||||||||||||||
| 315 | 766 | ▶ | if (ref $res eq 'ARRAY') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 316 | 745 | $body_filter->($cb, $res); | |||||||||||||||||||||||||||||||||||||||||
| 317 | 745 | return $res; | |||||||||||||||||||||||||||||||||||||||||
| 318 | } elsif (ref $res eq 'CODE') { | ||||||||||||||||||||||||||||||||||||||||||
| 319 | 21 | ▶ | return sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 320 | 21 | my $respond = shift; | |||||||||||||||||||||||||||||||||||||||||
| 321 | 21 | my $cb = $cb; # To avoid the nested closure leak for 5.8.x | |||||||||||||||||||||||||||||||||||||||||
| 322 | 21 | ▶ | $res->(sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||
| 323 | 21 | my $res = shift; | |||||||||||||||||||||||||||||||||||||||||
| 324 | 21 | my $filter_cb = $body_filter->($cb, $res); | |||||||||||||||||||||||||||||||||||||||||
| 325 | 19 | ▶ | if ($filter_cb) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 326 | 7 | my $writer = $respond->($res); | |||||||||||||||||||||||||||||||||||||||||
| 327 | 7 | ▶ | if ($writer) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 328 | return Plack::Util::inline_object | ||||||||||||||||||||||||||||||||||||||||||
| 329 | 10 | ▶ | write => sub { $writer->write($filter_cb->(@_)) }, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 330 | 7 | ▶ | close => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=7.1
| |||||||||||||||||||||||||||||||||||||||||||
| 331 | 7 | my $chunk = $filter_cb->(undef); | |||||||||||||||||||||||||||||||||||||||||
| 332 | 7 | ▶ | $writer->write($chunk) if defined $chunk; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 333 | 7 | $writer->close; | |||||||||||||||||||||||||||||||||||||||||
| 334 | 7 | }; | |||||||||||||||||||||||||||||||||||||||||
| 335 | } | ||||||||||||||||||||||||||||||||||||||||||
| 336 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 337 | 12 | return $respond->($res); | |||||||||||||||||||||||||||||||||||||||||
| 338 | } | ||||||||||||||||||||||||||||||||||||||||||
| 339 | 21 | }); | |||||||||||||||||||||||||||||||||||||||||
| 340 | 21 | }; | |||||||||||||||||||||||||||||||||||||||||
| 341 | } | ||||||||||||||||||||||||||||||||||||||||||
| 342 | |||||||||||||||||||||||||||||||||||||||||||
| 343 | 0 | return $res; | |||||||||||||||||||||||||||||||||||||||||
| 344 | } | ||||||||||||||||||||||||||||||||||||||||||
| 345 | |||||||||||||||||||||||||||||||||||||||||||
| 346 | package Plack::Util::Prototype; | ||||||||||||||||||||||||||||||||||||||||||
| 347 | |||||||||||||||||||||||||||||||||||||||||||
| 348 | 155 | our $AUTOLOAD; | |||||||||||||||||||||||||||||||||||||||||
| 349 | 3 | ▶ | sub can { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
can: called CC=2 SCAR=9.2
| |||||||||||||||||||||||||||||||||||||||||||
| 350 | 3 | ▶ | return $_[0]->{$_[1]} if Scalar::Util::blessed($_[0]); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 351 | 0 | goto &UNIVERSAL::can; | |||||||||||||||||||||||||||||||||||||||||
| 352 | } | ||||||||||||||||||||||||||||||||||||||||||
| 353 | |||||||||||||||||||||||||||||||||||||||||||
| 354 | 1997 | ▶ | sub AUTOLOAD { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
AUTOLOAD: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 355 | 1997 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 356 | 1997 | my $attr = $AUTOLOAD; | |||||||||||||||||||||||||||||||||||||||||
| 357 | 1997 | $attr =~ s/.*://; | |||||||||||||||||||||||||||||||||||||||||
| 358 | 1997 | ▶ | if (ref($self->{$attr}) eq 'CODE') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 359 | 1996 | $self->{$attr}->(@_); | |||||||||||||||||||||||||||||||||||||||||
| 360 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 361 | 1 | Carp::croak(qq/Can't locate object method "$attr" via package "Plack::Util::Prototype"/); | |||||||||||||||||||||||||||||||||||||||||
| 362 | } | ||||||||||||||||||||||||||||||||||||||||||
| 363 | } | ||||||||||||||||||||||||||||||||||||||||||
| 364 | |||||||||||||||||||||||||||||||||||||||||||
| 365 | 0 | ▶ | sub DESTROY { } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
DESTROY: not called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 366 | |||||||||||||||||||||||||||||||||||||||||||
| 367 | package Plack::Util::IOWithPath; | ||||||||||||||||||||||||||||||||||||||||||
| 368 | 155 | ▶ | use parent qw(IO::Handle); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 369 | |||||||||||||||||||||||||||||||||||||||||||
| 370 | 22 | ▶ | sub path { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
path: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 371 | 22 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 372 | 22 | ▶ | if (@_) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 373 | 20 | ${*$self}{+__PACKAGE__} = shift; | |||||||||||||||||||||||||||||||||||||||||
| 374 | } | ||||||||||||||||||||||||||||||||||||||||||
| 375 | 22 | ${*$self}{+__PACKAGE__}; | |||||||||||||||||||||||||||||||||||||||||
| 376 | } | ||||||||||||||||||||||||||||||||||||||||||
| 377 | |||||||||||||||||||||||||||||||||||||||||||
| 378 | package Plack::Util; | ||||||||||||||||||||||||||||||||||||||||||
| 379 | |||||||||||||||||||||||||||||||||||||||||||
| 380 | 155 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 381 | |||||||||||||||||||||||||||||||||||||||||||
| 382 | __END__ | ||||||||||||||||||||||||||||||||||||||||||