| 1 | package Plack::Request; | ||||||||||||||||||||||||||||||||||||||||||||||
| 2 | 67 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 67 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 67 | ▶ | use 5.008_001; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 67 | our $VERSION = '1.0057'; | |||||||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||||||||
| 7 | 67 | ▶ | use HTTP::Headers::Fast; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 67 | ▶ | use Carp (); | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 67 | ▶ | use Hash::MultiValue; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 67 | ▶ | use Plack::Request::Upload; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 67 | ▶ | use Stream::Buffered; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 67 | ▶ | use URI; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 14 | 67 | ▶ | use URI::Escape (); | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 15 | 67 | ▶ | use Cookie::Baker (); | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||||||||||||||||||||
| 17 | 67 | ▶ | use HTTP::Entity::Parser; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 18 | 67 | ▶ | use WWW::Form::UrlEncoded qw/parse_urlencoded_arrayref/; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||||||||||||||||
| 20 | 68 | ▶ | sub new { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=3 SCAR=12.5
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 21 | 68 | my($class, $env) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 22 | 68 | ▶ | Carp::croak(q{$env is required}) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $env and ref $env eq "HASH"
MC/DC0%0/2
defined $env and ref $env eq "HASH"
defined $env
ref $env eq "HASH"
Truth table33%1/3
A and B
A= defined $envB= ref $env eq "HASH"
| |||||||||||||||||||||||||||||||||||||||||||||||
| 23 | unless defined $env && ref($env) eq 'HASH'; | ||||||||||||||||||||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||||||||||||||||||||
| 25 | 68 | bless { env => $env }, $class; | |||||||||||||||||||||||||||||||||||||||||||||
| 26 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||||||||||||||||||||
| 28 | 436 | ▶ | sub env { $_[0]->{env} } | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
env: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||||||||||||||||||||
| 30 | 2 | ▶ | sub address { $_[0]->env->{REMOTE_ADDR} } | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
address: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 31 | 1 | ▶ | sub remote_host { $_[0]->env->{REMOTE_HOST} } | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
remote_host: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 32 | 1 | ▶ | sub protocol { $_[0]->env->{SERVER_PROTOCOL} } | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
protocol: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 33 | 1 | ▶ | sub method { $_[0]->env->{REQUEST_METHOD} } | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
method: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 34 | 1 | ▶ | sub port { $_[0]->env->{SERVER_PORT} } | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
port: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 35 | 0 | ▶ | sub user { $_[0]->env->{REMOTE_USER} } | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
user: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 36 | 2 | ▶ | sub request_uri { $_[0]->env->{REQUEST_URI} } | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
request_uri: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 37 | 3 | ▶ | sub path_info { $_[0]->env->{PATH_INFO} } | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
path_info: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 38 | 4 | ▶ | sub path { $_[0]->env->{PATH_INFO} || '/' } | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
path: called CC=2 SCAR=7.6
Pod
documented
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 39 | 2 | ▶ | sub query_string{ $_[0]->env->{QUERY_STRING} } | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
query_string: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 40 | 0 | ▶ | sub script_name { $_[0]->env->{SCRIPT_NAME} } | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
script_name: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 41 | 1 | ▶ | sub scheme { $_[0]->env->{'psgi.url_scheme'} } | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
scheme: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 42 | 0 | ▶ | sub secure { $_[0]->scheme eq 'https' } | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
secure: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 43 | 0 | ▶ | sub body { $_[0]->env->{'psgi.input'} } | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
body: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 44 | 13 | ▶ | sub input { $_[0]->env->{'psgi.input'} } | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
input: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||||||||||||||||||||
| 46 | 0 | ▶ | sub content_length { $_[0]->env->{CONTENT_LENGTH} } | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
content_length: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 47 | 0 | ▶ | sub content_type { $_[0]->env->{CONTENT_TYPE} } | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
content_type: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||||||||||||||||||||
| 49 | 0 | ▶ | sub session { $_[0]->env->{'psgix.session'} } | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
session: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 50 | 0 | ▶ | sub session_options { $_[0]->env->{'psgix.session.options'} } | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
session_options: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 51 | 0 | ▶ | sub logger { $_[0]->env->{'psgix.logger'} } | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
logger: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||||||||||||||||||||
| 53 | 13 | ▶ | sub cookies { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
cookies: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 54 | 13 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||||||||||||||||||||
| 56 | 13 | ▶ | return {} unless $self->env->{HTTP_COOKIE}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||||||||||||||||||||
| 58 | # HTTP_COOKIE hasn't changed: reuse the parsed cookie | ||||||||||||||||||||||||||||||||||||||||||||||
| 59 | 12 | ▶ | if ( $self->env->{'plack.cookie.parsed'} | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$self->env->{"plack.cookie.parsed"} and $self->env->{"plack.cookie.string"} eq $self->env->{"HTTP_COOKIE"}
MC/DC50%1/2
$self->env->{"plack.cookie.parsed"} and $self->env->{"plack.cookie.string"} eq $self->env->{"HTTP_COOKIE"}
$self->env->{"plack.cookie.parsed"}
$self->env->{"plack.cookie.string"} eq $self->env->{"HTTP_COOKIE"}
Truth table66%2/3
A and B
A= $self->env->{"plack.cookie.parsed"}B= $self->env->{"plack.cookie.string"} eq $self->env->{"HTTP_COOKIE"}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 60 | && $self->env->{'plack.cookie.string'} eq $self->env->{HTTP_COOKIE}) { | ||||||||||||||||||||||||||||||||||||||||||||||
| 61 | 11 | return $self->env->{'plack.cookie.parsed'}; | |||||||||||||||||||||||||||||||||||||||||||||
| 62 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||||||||||||||||||||
| 64 | 1 | $self->env->{'plack.cookie.string'} = $self->env->{HTTP_COOKIE}; | |||||||||||||||||||||||||||||||||||||||||||||
| 65 | 1 | $self->env->{'plack.cookie.parsed'} = Cookie::Baker::crush_cookie($self->env->{'plack.cookie.string'}); | |||||||||||||||||||||||||||||||||||||||||||||
| 66 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||||||||||||||||||||
| 68 | 13 | ▶ | sub content { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
content: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 69 | 13 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||||||||||||||||||||
| 71 | 13 | ▶ | unless ($self->env->{'psgix.input.buffered'}) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 72 | 7 | $self->_parse_request_body; | |||||||||||||||||||||||||||||||||||||||||||||
| 73 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||||||||||||||||||||
| 75 | 13 | ▶ | my $fh = $self->input or return ''; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 76 | 13 | ▶ | my $cl = $self->env->{CONTENT_LENGTH} or return ''; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||||||||||||||||||||
| 78 | 9 | $fh->seek(0, 0); # just in case middleware/apps read it without seeking back | |||||||||||||||||||||||||||||||||||||||||||||
| 79 | 9 | $fh->read(my($content), $cl, 0); | |||||||||||||||||||||||||||||||||||||||||||||
| 80 | 9 | $fh->seek(0, 0); | |||||||||||||||||||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||||||||||||||||||||
| 82 | 9 | return $content; | |||||||||||||||||||||||||||||||||||||||||||||
| 83 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||||||||||||||||||||
| 85 | 0 | ▶ | sub raw_body { $_[0]->content } | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
raw_body: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||||||||||||||||||||
| 87 | # XXX you can mutate headers with ->headers but it's not written through to the env | ||||||||||||||||||||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||||||||||||||||||||
| 89 | 2 | ▶ | sub headers { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
headers: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 90 | 2 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 91 | 2 | ▶ | if (!defined $self->{headers}) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 92 | 2 | my $env = $self->env; | |||||||||||||||||||||||||||||||||||||||||||||
| 93 | $self->{headers} = HTTP::Headers::Fast->new( | ||||||||||||||||||||||||||||||||||||||||||||||
| 94 | map { | ||||||||||||||||||||||||||||||||||||||||||||||
| 95 | 8 | (my $field = $_) =~ s/^HTTPS?_//; | |||||||||||||||||||||||||||||||||||||||||||||
| 96 | 8 | ( lc($field) => $env->{$_} ); | |||||||||||||||||||||||||||||||||||||||||||||
| 97 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 98 | 2 | grep { /^(?:HTTP|CONTENT)_/ } keys %$env | |||||||||||||||||||||||||||||||||||||||||||||
| 99 | ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 100 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 101 | 2 | $self->{headers}; | |||||||||||||||||||||||||||||||||||||||||||||
| 102 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||||||||||||||||||||
| 104 | 0 | ▶ | sub content_encoding { shift->headers->content_encoding(@_) } | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
content_encoding: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 105 | 0 | ▶ | sub header { shift->headers->header(@_) } | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
header: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 106 | 0 | ▶ | sub referer { shift->headers->referer(@_) } | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
referer: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 107 | 0 | ▶ | sub user_agent { shift->headers->user_agent(@_) } | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
user_agent: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||||||||||||||||||||
| 109 | 12 | ▶ | sub _body_parameters { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_body_parameters: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||
| 110 | 12 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 111 | 12 | ▶ | unless ($self->env->{'plack.request.body_parameters'}) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 112 | 10 | $self->_parse_request_body; | |||||||||||||||||||||||||||||||||||||||||||||
| 113 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 114 | 11 | return $self->env->{'plack.request.body_parameters'}; | |||||||||||||||||||||||||||||||||||||||||||||
| 115 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 116 | |||||||||||||||||||||||||||||||||||||||||||||||
| 117 | 27 | ▶ | sub _query_parameters { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_query_parameters: called CC=2 SCAR=7.1
| |||||||||||||||||||||||||||||||||||||||||||||||
| 118 | 27 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 119 | 27 | ▶ | $self->env->{'plack.request.query_parameters'} ||= parse_urlencoded_arrayref($self->env->{'QUERY_STRING'}); | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$self->env->{"plack.request.query_parameters"} ||= parse_urlencoded_arrayref($self->env->{"QUERY_STRING"})
MC/DC0%0/2
$self->env->{"plack.request.query_parameters"} ||= parse_urlencoded_arrayref($self->env->{"QUERY_STRING"})
$self->env->{"plack.request.query_parameters"}
parse_urlencoded_arrayref($self->env->{"QUERY_STRING"})
Truth table66%2/3
A ||= B
A= $self->env->{"plack.request.query_parameters"}B= parse_urlencoded_arrayref($self->env->{"QUERY_STRING"})
| |||||||||||||||||||||||||||||||||||||||||||||||
| 120 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 121 | |||||||||||||||||||||||||||||||||||||||||||||||
| 122 | 18 | ▶ | sub query_parameters { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
query_parameters: called CC=2 SCAR=7.6
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 123 | 18 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 124 | 18 | ▶ | $self->env->{'plack.request.query'} ||= Hash::MultiValue->new(@{$self->_query_parameters}); | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$self->env->{"plack.request.query"} ||= "Hash::MultiValue"->new(@{$self->_query_parameters;})
MC/DC0%0/2
$self->env->{"plack.request.query"} ||= "Hash::MultiValue"->new(@{$self->_query_parameters;})
$self->env->{"plack.request.query"}
"Hash::MultiValue"->new(@{$self->_query_parameters;})
Truth table33%1/3
A ||= B
A= $self->env->{"plack.request.query"}B= "Hash::MultiValue"->new(@{$self->_query_parameters;})
| |||||||||||||||||||||||||||||||||||||||||||||||
| 125 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 126 | |||||||||||||||||||||||||||||||||||||||||||||||
| 127 | 3 | ▶ | sub body_parameters { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
body_parameters: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 128 | 3 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 129 | 3 | ▶ | $self->env->{'plack.request.body'} ||= Hash::MultiValue->new(@{$self->_body_parameters}); | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$self->env->{"plack.request.body"} ||= "Hash::MultiValue"->new(@{$self->_body_parameters;})
MC/DC50%1/2
$self->env->{"plack.request.body"} ||= "Hash::MultiValue"->new(@{$self->_body_parameters;})
$self->env->{"plack.request.body"}
"Hash::MultiValue"->new(@{$self->_body_parameters;})
Truth table66%2/3
A ||= B
A= $self->env->{"plack.request.body"}B= "Hash::MultiValue"->new(@{$self->_body_parameters;})
| |||||||||||||||||||||||||||||||||||||||||||||||
| 130 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 131 | |||||||||||||||||||||||||||||||||||||||||||||||
| 132 | # contains body + query | ||||||||||||||||||||||||||||||||||||||||||||||
| 133 | 17 | ▶ | sub parameters { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
parameters: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 134 | 17 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 135 | |||||||||||||||||||||||||||||||||||||||||||||||
| 136 | 17 | ▶ | $self->env->{'plack.request.merged'} ||= do { | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$self->env->{"plack.request.merged"} ||= do {
"Hash::MultiValue"->new(@{$self->_query_parameters;}, @{$self->_body_parameters;})
}
MC/DC0%0/2
$self->env->{"plack.request.merged"} ||= do {
"Hash::MultiValue"->new(@{$self->_query_parameters;}, @{$self->_body_parameters;})
}
$self->env->{"plack.request.merged"}
do {
"Hash::MultiValue"->new(@{$self->_query_parameters;}, @{$self->_body_parameters;})
}
Truth table66%2/3
A ||= B
A= $self->env->{"plack.request.merged"}B= do {
"Hash::MultiValue"->new(@{$self->_query_parameters;}, @{$self->_body_parameters;})
}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 137 | Hash::MultiValue->new( | ||||||||||||||||||||||||||||||||||||||||||||||
| 138 | 9 | @{$self->_query_parameters}, | |||||||||||||||||||||||||||||||||||||||||||||
| 139 | 9 | @{$self->_body_parameters} | |||||||||||||||||||||||||||||||||||||||||||||
| 140 | ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 141 | }; | ||||||||||||||||||||||||||||||||||||||||||||||
| 142 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 143 | |||||||||||||||||||||||||||||||||||||||||||||||
| 144 | 16 | ▶ | sub uploads { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
uploads: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 145 | 16 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 146 | |||||||||||||||||||||||||||||||||||||||||||||||
| 147 | 16 | ▶ | if ($self->env->{'plack.request.upload'}) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 148 | 13 | return $self->env->{'plack.request.upload'}; | |||||||||||||||||||||||||||||||||||||||||||||
| 149 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 150 | |||||||||||||||||||||||||||||||||||||||||||||||
| 151 | 3 | $self->_parse_request_body; | |||||||||||||||||||||||||||||||||||||||||||||
| 152 | 3 | return $self->env->{'plack.request.upload'}; | |||||||||||||||||||||||||||||||||||||||||||||
| 153 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 154 | |||||||||||||||||||||||||||||||||||||||||||||||
| 155 | 8 | ▶ | sub param { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
param: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 156 | 8 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 157 | |||||||||||||||||||||||||||||||||||||||||||||||
| 158 | 8 | ▶ | return keys %{ $self->parameters } if @_ == 0; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 159 | |||||||||||||||||||||||||||||||||||||||||||||||
| 160 | 5 | my $key = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 161 | 5 | ▶ | return $self->parameters->{$key} unless wantarray; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 162 | 2 | return $self->parameters->get_all($key); | |||||||||||||||||||||||||||||||||||||||||||||
| 163 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 164 | |||||||||||||||||||||||||||||||||||||||||||||||
| 165 | 11 | ▶ | sub upload { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
upload: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 166 | 11 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 167 | |||||||||||||||||||||||||||||||||||||||||||||||
| 168 | 11 | ▶ | return keys %{ $self->uploads } if @_ == 0; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 169 | |||||||||||||||||||||||||||||||||||||||||||||||
| 170 | 10 | my $key = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 171 | 10 | ▶ | return $self->uploads->{$key} unless wantarray; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 172 | 6 | return $self->uploads->get_all($key); | |||||||||||||||||||||||||||||||||||||||||||||
| 173 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 174 | |||||||||||||||||||||||||||||||||||||||||||||||
| 175 | 21 | ▶ | sub uri { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
uri: called CC=5 SCAR=16.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 176 | 21 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 177 | |||||||||||||||||||||||||||||||||||||||||||||||
| 178 | 21 | my $base = $self->_uri_base; | |||||||||||||||||||||||||||||||||||||||||||||
| 179 | |||||||||||||||||||||||||||||||||||||||||||||||
| 180 | # We have to escape back PATH_INFO in case they include stuff like | ||||||||||||||||||||||||||||||||||||||||||||||
| 181 | # ? or # so that the URI parser won't be tricked. However we should | ||||||||||||||||||||||||||||||||||||||||||||||
| 182 | # preserve '/' since encoding them into %2f doesn't make sense. | ||||||||||||||||||||||||||||||||||||||||||||||
| 183 | # This means when a request like /foo%2fbar comes in, we recognize | ||||||||||||||||||||||||||||||||||||||||||||||
| 184 | # it as /foo/bar which is not ideal, but that's how the PSGI PATH_INFO | ||||||||||||||||||||||||||||||||||||||||||||||
| 185 | # spec goes and we can't do anything about it. See PSGI::FAQ for details. | ||||||||||||||||||||||||||||||||||||||||||||||
| 186 | |||||||||||||||||||||||||||||||||||||||||||||||
| 187 | # See RFC 3986 before modifying. | ||||||||||||||||||||||||||||||||||||||||||||||
| 188 | 21 | my $path_escape_class = q{^/;:@&=A-Za-z0-9\$_.+!*'(),-}; | |||||||||||||||||||||||||||||||||||||||||||||
| 189 | |||||||||||||||||||||||||||||||||||||||||||||||
| 190 | 21 | ▶ | my $path = URI::Escape::uri_escape($self->env->{PATH_INFO} || '', $path_escape_class); | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$self->env->{'PATH_INFO'} || ''
MC/DC100%1/1
$self->env->{'PATH_INFO'} || ''
$self->env->{'PATH_INFO'}
Truth table100%2/2
A
A= $self->env->{'PATH_INFO'}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 191 | $path .= '?' . $self->env->{QUERY_STRING} | ||||||||||||||||||||||||||||||||||||||||||||||
| 192 | 21 | ▶ | if defined $self->env->{QUERY_STRING} && $self->env->{QUERY_STRING} ne ''; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
defined $self->env->{"QUERY_STRING"} and $self->env->{"QUERY_STRING"} ne ""
MC/DC100%2/2
defined $self->env->{"QUERY_STRING"} and $self->env->{"QUERY_STRING"} ne ""
defined $self->env->{"QUERY_STRING"}
$self->env->{"QUERY_STRING"} ne ""
Truth table100%3/3
A and B
A= defined $self->env->{"QUERY_STRING"}B= $self->env->{"QUERY_STRING"} ne ""
| |||||||||||||||||||||||||||||||||||||||||||||||
| 193 | |||||||||||||||||||||||||||||||||||||||||||||||
| 194 | 21 | ▶ | $base =~ s!/$!! if $path =~ m!^/!; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 195 | |||||||||||||||||||||||||||||||||||||||||||||||
| 196 | 21 | return URI->new($base . $path)->canonical; | |||||||||||||||||||||||||||||||||||||||||||||
| 197 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 198 | |||||||||||||||||||||||||||||||||||||||||||||||
| 199 | 9 | ▶ | sub base { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
base: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 200 | 9 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 201 | 9 | URI->new($self->_uri_base)->canonical; | |||||||||||||||||||||||||||||||||||||||||||||
| 202 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 203 | |||||||||||||||||||||||||||||||||||||||||||||||
| 204 | 30 | ▶ | sub _uri_base { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_uri_base: called CC=6 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||||||
| 205 | 30 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 206 | |||||||||||||||||||||||||||||||||||||||||||||||
| 207 | 30 | my $env = $self->env; | |||||||||||||||||||||||||||||||||||||||||||||
| 208 | |||||||||||||||||||||||||||||||||||||||||||||||
| 209 | my $uri = ($env->{'psgi.url_scheme'} || "http") . | ||||||||||||||||||||||||||||||||||||||||||||||
| 210 | "://" . | ||||||||||||||||||||||||||||||||||||||||||||||
| 211 | ($env->{HTTP_HOST} || (($env->{SERVER_NAME} || "") . ":" . ($env->{SERVER_PORT} || 80))) . | ||||||||||||||||||||||||||||||||||||||||||||||
| 212 | 30 | ▶ | ($env->{SCRIPT_NAME} || '/'); | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition90%9/10
$env->{'psgi.url_scheme'} || 'http'
$env->{'HTTP_HOST'} || ($env->{'SERVER_NAME'} || '') . ':' . ($env->{'SERVER_PORT'} || 80)
$env->{'SERVER_NAME'} || ''
$env->{'SERVER_PORT'} || 80
$env->{'SCRIPT_NAME'} || '/'
MC/DC100%1/1
$env->{'psgi.url_scheme'} || 'http'
$env->{'psgi.url_scheme'}
MC/DC100%1/1
$env->{'HTTP_HOST'} || ($env->{'SERVER_NAME'} || '') . ':' . ($env->{'SERVER_PORT'} || 80)
$env->{'HTTP_HOST'}
MC/DC0%0/1
$env->{'SERVER_PORT'} || 80
$env->{'SERVER_PORT'}
MC/DC100%1/1
$env->{'SCRIPT_NAME'} || '/'
$env->{'SCRIPT_NAME'}
Truth table100%2/2
A
A= $env->{'psgi.url_scheme'}
Truth table100%2/2
A
A= $env->{'HTTP_HOST'}
Truth table50%1/2
A
A= $env->{'SERVER_PORT'}
Truth table100%2/2
A
A= $env->{'SCRIPT_NAME'}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 213 | |||||||||||||||||||||||||||||||||||||||||||||||
| 214 | 30 | return $uri; | |||||||||||||||||||||||||||||||||||||||||||||
| 215 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 216 | |||||||||||||||||||||||||||||||||||||||||||||||
| 217 | 17 | ▶ | sub new_response { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new_response: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 218 | 17 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 219 | 17 | require Plack::Response; | |||||||||||||||||||||||||||||||||||||||||||||
| 220 | 17 | Plack::Response->new(@_); | |||||||||||||||||||||||||||||||||||||||||||||
| 221 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 222 | |||||||||||||||||||||||||||||||||||||||||||||||
| 223 | 20 | ▶ | sub request_body_parser { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
request_body_parser: called CC=2 SCAR=8.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 224 | 20 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 225 | 20 | ▶ | $self->{request_body_parser} ||= $self->_build_body_parser; | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$self->{"request_body_parser"} ||= $self->_build_body_parser
MC/DC0%0/2
$self->{"request_body_parser"} ||= $self->_build_body_parser
$self->{"request_body_parser"}
$self->_build_body_parser
Truth table33%1/3
A ||= B
A= $self->{"request_body_parser"}B= $self->_build_body_parser
| |||||||||||||||||||||||||||||||||||||||||||||||
| 226 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 227 | |||||||||||||||||||||||||||||||||||||||||||||||
| 228 | 20 | ▶ | sub _build_body_parser { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_build_body_parser: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 229 | 20 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 230 | |||||||||||||||||||||||||||||||||||||||||||||||
| 231 | 20 | my $len = $self->_buffer_length_for($self->env); | |||||||||||||||||||||||||||||||||||||||||||||
| 232 | |||||||||||||||||||||||||||||||||||||||||||||||
| 233 | 20 | my $parser = HTTP::Entity::Parser->new(buffer_length => $len); | |||||||||||||||||||||||||||||||||||||||||||||
| 234 | 20 | $parser->register('application/x-www-form-urlencoded', 'HTTP::Entity::Parser::UrlEncoded'); | |||||||||||||||||||||||||||||||||||||||||||||
| 235 | 20 | $parser->register('multipart/form-data', 'HTTP::Entity::Parser::MultiPart'); | |||||||||||||||||||||||||||||||||||||||||||||
| 236 | |||||||||||||||||||||||||||||||||||||||||||||||
| 237 | 20 | $parser; | |||||||||||||||||||||||||||||||||||||||||||||
| 238 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 239 | |||||||||||||||||||||||||||||||||||||||||||||||
| 240 | 20 | ▶ | sub _buffer_length_for { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_buffer_length_for: called CC=3 SCAR=12.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 241 | 20 | my($self, $env) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 242 | |||||||||||||||||||||||||||||||||||||||||||||||
| 243 | 20 | ▶ | return $ENV{PLACK_BUFFER_LENGTH} if defined $ENV{PLACK_BUFFER_LENGTH}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 244 | |||||||||||||||||||||||||||||||||||||||||||||||
| 245 | 20 | ▶ | if ($env->{'psgix.input.buffered'}) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 246 | 0 | return 1024 * 1024; # 1MB for buffered | |||||||||||||||||||||||||||||||||||||||||||||
| 247 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 248 | 20 | return 1024 * 64; # 64K for unbuffered | |||||||||||||||||||||||||||||||||||||||||||||
| 249 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 250 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 251 | |||||||||||||||||||||||||||||||||||||||||||||||
| 252 | 20 | ▶ | sub _parse_request_body { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_parse_request_body: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||
| 253 | 20 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 254 | |||||||||||||||||||||||||||||||||||||||||||||||
| 255 | 20 | my ($params,$uploads) = $self->request_body_parser->parse($self->env); | |||||||||||||||||||||||||||||||||||||||||||||
| 256 | 19 | $self->env->{'plack.request.body_parameters'} = $params; | |||||||||||||||||||||||||||||||||||||||||||||
| 257 | |||||||||||||||||||||||||||||||||||||||||||||||
| 258 | 19 | my $upload_hash = Hash::MultiValue->new(); | |||||||||||||||||||||||||||||||||||||||||||||
| 259 | 19 | ▶ | while ( my ($k,$v) = splice @$uploads, 0, 2 ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 260 | 10 | my %copy = %$v; | |||||||||||||||||||||||||||||||||||||||||||||
| 261 | 10 | $copy{headers} = HTTP::Headers::Fast->new(@{$v->{headers}}); | |||||||||||||||||||||||||||||||||||||||||||||
| 262 | 10 | $upload_hash->add($k, Plack::Request::Upload->new(%copy)); | |||||||||||||||||||||||||||||||||||||||||||||
| 263 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 264 | 19 | $self->env->{'plack.request.upload'} = $upload_hash; | |||||||||||||||||||||||||||||||||||||||||||||
| 265 | 19 | 1; | |||||||||||||||||||||||||||||||||||||||||||||
| 266 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 267 | |||||||||||||||||||||||||||||||||||||||||||||||
| 268 | 67 | 1; | |||||||||||||||||||||||||||||||||||||||||||||
| 269 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||