| 1 | package Dancer::Request; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | 207 | our $AUTHORITY = 'cpan:SUKRIA'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | #ABSTRACT: interface for accessing incoming requests | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 207 | $Dancer::Request::VERSION = '1.3522'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 207 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | 207 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | 207 | ▶ | use Carp; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 207 | ▶ | use base 'Dancer::Object'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 207 | ▶ | use Dancer::Config 'setting'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 207 | ▶ | use Dancer::Request::Upload; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 207 | ▶ | use Dancer::SharedData; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | 207 | ▶ | use Dancer::Session; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | 207 | ▶ | use Dancer::Exception qw(:all); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 207 | ▶ | use Encode; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | 207 | ▶ | use HTTP::Body; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | 207 | ▶ | use URI; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 207 | ▶ | use URI::Escape; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | 207 | my @http_env_keys = ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | 'user_agent', 'accept_language', 'accept_charset', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | 'accept_encoding', 'keep_alive', 'connection', 'accept', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | 'accept_type', 'referer', #'host', managed manually | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | 207 | my $count = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | 207 | __PACKAGE__->attributes( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | # query | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | 'env', 'path', 'method', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | 'content_type', 'content_length', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | 'id', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | 'uploads', 'headers', 'path_info', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | 'ajax', 'is_forward', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | @http_env_keys, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | 615 | ▶ | sub new { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=2 SCAR=8.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | 615 | my ($self, @args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | 615 | ▶ | if (@args == 1) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | 0 | @args = ('env' => $args[0]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | 0 | Dancer::Deprecation->deprecated( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | fatal => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | feature => 'Calling Dancer::Request->new($env)', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | version => 1.3059, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | reason => 'Please use Dancer::Request->new( env => $env ) instead', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | 615 | $self->SUPER::new(@args); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | # aliases | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | 1 | ▶ | sub agent { $_[0]->user_agent } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
agent: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | 21 | ▶ | sub remote_address { $_[0]->address } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
remote_address: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | 1 | ▶ | sub forwarded_for_address { $_[0]->env->{'X_FORWARDED_FOR'} || $_[0]->env->{'HTTP_X_FORWARDED_FOR'} } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
forwarded_for_address: called CC=2 SCAR=7.6
Pod
documented
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | 21 | ▶ | sub address { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
address: called CC=2 SCAR=7.6
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | setting('behind_proxy') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | ? $_[0]->forwarded_for_address() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | : $_[0]->env->{REMOTE_ADDR} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | 21 | ▶ | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | 34 | ▶ | sub host { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
host: called CC=6 SCAR=18.7
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | 34 | ▶ | if (@_==2) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | 0 | $_[0]->{host} = $_[1]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | 34 | my $host; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | 34 | ▶ | $host = ($_[0]->env->{X_FORWARDED_HOST} || $_[0]->env->{HTTP_X_FORWARDED_HOST}) if setting('behind_proxy'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$_[0]->env->{'X_FORWARDED_HOST'} || $_[0]->env->{'HTTP_X_FORWARDED_HOST'}
MC/DC0%0/2
$_[0]->env->{'X_FORWARDED_HOST'} || $_[0]->env->{'HTTP_X_FORWARDED_HOST'}
$_[0]->env->{'X_FORWARDED_HOST'}
$_[0]->env->{'HTTP_X_FORWARDED_HOST'}
Truth table33%1/3
A || B
A= $_[0]->env->{'X_FORWARDED_HOST'}B= $_[0]->env->{'HTTP_X_FORWARDED_HOST'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | 34 | ▶ | $host || $_[0]->{host} || $_[0]->env->{HTTP_HOST}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$host or $_[0]{"host"}
MC/DC100%2/2
$host or $_[0]{"host"}
$host
$_[0]{"host"}
Truth table100%3/3
A or B
A= $hostB= $_[0]{"host"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | 0 | ▶ | sub remote_host { $_[0]->env->{REMOTE_HOST} } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
remote_host: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | 1 | ▶ | sub protocol { $_[0]->env->{SERVER_PROTOCOL} } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
protocol: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | 1 | ▶ | sub port { $_[0]->env->{SERVER_PORT} } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
port: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | 625 | ▶ | sub request_uri { $_[0]->env->{REQUEST_URI} } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
request_uri: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | 1 | ▶ | sub user { $_[0]->env->{REMOTE_USER} } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
user: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | 626 | ▶ | sub script_name { $_[0]->env->{SCRIPT_NAME} } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
script_name: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | 1 | ▶ | sub request_base { $_[0]->env->{REQUEST_BASE} || $_[0]->env->{HTTP_REQUEST_BASE} } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
request_base: called CC=2 SCAR=7.6
Pod
documented
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | 33 | ▶ | sub scheme { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
scheme: called CC=10 SCAR=23.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | 33 | my $scheme; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | 33 | ▶ | if (setting('behind_proxy')) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | # PSGI specs say that X_FORWARDED_PROTO will | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | # be converted into HTTP_X_FORWARDED_PROTO | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | # but Dancer::Test doesn't use PSGI (for now) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | $scheme = $_[0]->env->{'HTTP_X_FORWARDED_PROTO'} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | || $_[0]->env->{'X_FORWARDED_PROTOCOL'} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | || $_[0]->env->{'HTTP_X_FORWARDED_PROTOCOL'} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | || $_[0]->env->{'HTTP_FORWARDED_PROTO'} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | 5 | ▶ | || $_[0]->env->{'X_FORWARDED_PROTO'} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition85%12/14
$_[0]->env->{'HTTP_X_FORWARDED_PROTO'} || $_[0]->env->{'X_FORWARDED_PROTOCOL'} || $_[0]->env->{'HTTP_X_FORWARDED_PROTOCOL'} || $_[0]->env->{'HTTP_FORWARDED_PROTO'} || $_[0]->env->{'X_FORWARDED_PROTO'} || ''
$_[0]->env->{"HTTP_X_FORWARDED_PROTO"} or $_[0]->env->{"X_FORWARDED_PROTOCOL"} or $_[0]->env->{"HTTP_X_FORWARDED_PROTOCOL"} or $_[0]->env->{"HTTP_FORWARDED_PROTO"} or $_[0]->env->{"X_FORWARDED_PROTO"}
$_[0]->env->{"HTTP_X_FORWARDED_PROTO"} or $_[0]->env->{"X_FORWARDED_PROTOCOL"} or $_[0]->env->{"HTTP_X_FORWARDED_PROTOCOL"} or $_[0]->env->{"HTTP_FORWARDED_PROTO"}
$_[0]->env->{"HTTP_X_FORWARDED_PROTO"} or $_[0]->env->{"X_FORWARDED_PROTOCOL"} or $_[0]->env->{"HTTP_X_FORWARDED_PROTOCOL"}
$_[0]->env->{"HTTP_X_FORWARDED_PROTO"} or $_[0]->env->{"X_FORWARDED_PROTOCOL"}
MC/DC60%3/5
$_[0]->env->{'HTTP_X_FORWARDED_PROTO'} || $_[0]->env->{'X_FORWARDED_PROTOCOL'} || $_[0]->env->{'HTTP_X_FORWARDED_PROTOCOL'} || $_[0]->env->{'HTTP_FORWARDED_PROTO'} || $_[0]->env->{'X_FORWARDED_PROTO'} || ''
$_[0]->env->{"HTTP_X_FORWARDED_PROTO"}
$_[0]->env->{"X_FORWARDED_PROTOCOL"}
$_[0]->env->{"HTTP_X_FORWARDED_PROTOCOL"}
$_[0]->env->{"HTTP_FORWARDED_PROTO"}
$_[0]->env->{"X_FORWARDED_PROTO"}
Truth table66%4/6
A or B or C or D or E
A= $_[0]->env->{"HTTP_X_FORWARDED_PROTO"}B= $_[0]->env->{"X_FORWARDED_PROTOCOL"}C= $_[0]->env->{"HTTP_X_FORWARDED_PROTOCOL"}D= $_[0]->env->{"HTTP_FORWARDED_PROTO"}E= $_[0]->env->{"X_FORWARDED_PROTO"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | || "" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | return $scheme | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | || $_[0]->env->{'psgi.url_scheme'} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | 33 | ▶ | || $_[0]->env->{'PSGI.URL_SCHEME'} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition87%7/8
$scheme || $_[0]->env->{'psgi.url_scheme'} || $_[0]->env->{'PSGI.URL_SCHEME'} || ''
$scheme or $_[0]->env->{"psgi.url_scheme"} or $_[0]->env->{"PSGI.URL_SCHEME"}
$scheme or $_[0]->env->{"psgi.url_scheme"}
MC/DC66%2/3
$scheme || $_[0]->env->{'psgi.url_scheme'} || $_[0]->env->{'PSGI.URL_SCHEME'} || ''
$scheme
$_[0]->env->{"psgi.url_scheme"}
$_[0]->env->{"PSGI.URL_SCHEME"}
Truth table75%3/4
A or B or C
A= $schemeB= $_[0]->env->{"psgi.url_scheme"}C= $_[0]->env->{"PSGI.URL_SCHEME"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | || ""; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | 1 | ▶ | sub secure { $_[0]->scheme eq 'https' } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
secure: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | 3 | ▶ | sub uri { $_[0]->request_uri } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
uri: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | 20 | ▶ | sub is_head { $_[0]->{method} eq 'HEAD' } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_head: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | 10 | ▶ | sub is_post { $_[0]->{method} eq 'POST' } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_post: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | 2 | ▶ | sub is_get { $_[0]->{method} eq 'GET' } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_get: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | 15 | ▶ | sub is_put { $_[0]->{method} eq 'PUT' } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_put: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | 2 | ▶ | sub is_delete { $_[0]->{method} eq 'DELETE' } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_delete: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | 1 | ▶ | sub is_patch { $_[0]->{method} eq 'PATCH' } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_patch: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | 7 | ▶ | sub header { $_[0]->{headers}->header($_[1]) } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
header: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | # We used to store the whole raw unparsed body; this was a big problem for large | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | # file uploads (Issue 1129). | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | # The original fix was to stop doing so, and replace the accessor with one that | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | # would read it out of the temp file returned by HTTP::Body->body - but that | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | # doesn't work for e.g. parsed form submissions, only certain types. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | # So, back to the older way - we may have a request body squirreled away | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | # in memory if the config included the raw_request_body_in_ram boolean | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | 17 | ▶ | sub body { $_[0]->{body} } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
body: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | # public interface compat with CGI.pm objects | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | 1 | ▶ | sub request_method { method(@_) } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
request_method: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | 2 | ▶ | sub Vars { params(@_) } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
Vars: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | 619 | ▶ | sub input_handle { $_[0]->env->{'psgi.input'} || $_[0]->env->{'PSGI.INPUT'} } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
input_handle: called CC=2 SCAR=6.9
Pod
documented
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | 615 | ▶ | sub init { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
init: called CC=9 SCAR=22.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | 615 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | 615 | ▶ | $self->{env} ||= {}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$self->{"env"} ||= {}
MC/DC0%0/1
$self->{"env"} ||= {}
$self->{"env"}
Truth table50%1/2
A
A= $self->{"env"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | 615 | $self->{path} = undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | 615 | $self->{method} = undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | 615 | $self->{params} = {}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | 615 | ▶ | $self->{is_forward} ||= 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$self->{"is_forward"} ||= 0
MC/DC100%1/1
$self->{"is_forward"} ||= 0
$self->{"is_forward"}
Truth table100%2/2
A
A= $self->{"is_forward"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | 615 | ▶ | $self->{content_length} = $self->env->{CONTENT_LENGTH} || 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$self->env->{'CONTENT_LENGTH'} || 0
MC/DC100%1/1
$self->env->{'CONTENT_LENGTH'} || 0
$self->env->{'CONTENT_LENGTH'}
Truth table100%2/2
A
A= $self->env->{'CONTENT_LENGTH'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | 615 | ▶ | $self->{content_type} = $self->env->{CONTENT_TYPE} || ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$self->env->{'CONTENT_TYPE'} || ''
MC/DC100%1/1
$self->env->{'CONTENT_TYPE'} || ''
$self->env->{'CONTENT_TYPE'}
Truth table100%2/2
A
A= $self->env->{'CONTENT_TYPE'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | 615 | $self->{id} = ++$count; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | 615 | $self->{_chunk_size} = 4096; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | 615 | $self->{_read_position} = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | 615 | $self->{_body_params} = undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | 615 | $self->{_query_params} = undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | 615 | $self->{_route_params} = {}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | 615 | $self->_build_headers(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | 615 | $self->_build_request_env(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | 615 | ▶ | $self->_build_path() unless $self->path; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | 615 | ▶ | $self->_build_path_info() unless $self->path_info; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | 615 | ▶ | $self->_build_method() unless $self->method; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | $self->{_http_body} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | 615 | = HTTP::Body->new($self->content_type, $self->content_length); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | 615 | $self->{_http_body}->cleanup(1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | 615 | $self->{body} = ''; # default, because we might not store it now. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | 615 | $self->_build_params(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | 615 | ▶ | $self->_build_uploads unless $self->uploads; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | 615 | $self->{ajax} = $self->is_ajax; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | 615 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | 1 | ▶ | sub to_string { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
to_string: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | 1 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | 1 | return "[#" . $self->id . "] " . $self->method . " " . $self->path; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | # helper for building a request object by hand | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | # with the given method, path, params, body and headers. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | 571 | ▶ | sub new_for_request { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new_for_request: called CC=10 SCAR=23.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | 571 | my ($class, $method, $uri, $params, $body, $headers, $extra_env) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | 571 | ▶ | $params ||= {}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$params ||= {}
MC/DC100%1/1
$params ||= {}
$params
Truth table100%2/2
A
A= $params
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | 571 | ▶ | $extra_env ||= {}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$extra_env ||= {}
MC/DC100%1/1
$extra_env ||= {}
$extra_env
Truth table100%2/2
A
A= $extra_env
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | 571 | $method = uc($method); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | 571 | my ( $path, $query_string ) = ( $uri =~ /([^?]*)(?:\?(.*))?/s ); #from HTTP::Server::Simple | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | my $env = { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | %ENV, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | 571 | ▶ | %{$extra_env}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%5/5
$query_string || $ENV{'QUERY_STRING'} || ''
$query_string or $ENV{"QUERY_STRING"}
MC/DC100%2/2
$query_string || $ENV{'QUERY_STRING'} || ''
$query_string
$ENV{"QUERY_STRING"}
Truth table100%3/3
A or B
A= $query_stringB= $ENV{"QUERY_STRING"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | PATH_INFO => $path, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | 571 | QUERY_STRING => $query_string || $ENV{QUERY_STRING} || '', | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | REQUEST_METHOD => $method | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | 571 | ▶ | $env->{CONTENT_LENGTH} = defined($body) ? length($body) : 0 if !exists $env->{CONTENT_LENGTH}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | 571 | my $req = $class->new(env => $env); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | 571 | $req->{params} = {%{$req->{params}}, %{$params}}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | 571 | $req->_build_params(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | 571 | $req->{_query_params} = $req->{params}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | 571 | my $store_raw_body = setting('raw_request_body_in_ram'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | 571 | ▶ | $store_raw_body = defined $store_raw_body ? $store_raw_body : 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | 571 | ▶ | if ($store_raw_body) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | 571 | $req->{body} = $body; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | 571 | ▶ | $req->{headers} = $headers || HTTP::Headers->new; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$headers || 'HTTP::Headers'->new
MC/DC0%0/2
$headers || 'HTTP::Headers'->new
$headers
'HTTP::Headers'->new
Truth table66%2/3
A || B
A= $headersB= 'HTTP::Headers'->new
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | 571 | return $req; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | #Create a new request which is a clone of the current one, apart | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | #from the path location, which points instead to the new location | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | 16 | ▶ | sub forward { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
forward: called CC=8 SCAR=20.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | 16 | my ($class, $request, $to_data) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | 16 | my $env = $request->env; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | 16 | $env->{PATH_INFO} = $to_data->{to_url}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | 16 | my $new_request = $class->new(env => $env, is_forward => 1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | my $new_params = _merge_params(scalar($request->params), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | 16 | ▶ | $to_data->{params} || {}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$to_data->{'params'} || {}
MC/DC100%1/1
$to_data->{'params'} || {}
$to_data->{'params'}
Truth table100%2/2
A
A= $to_data->{'params'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | 16 | ▶ | if (exists($to_data->{options}{method})) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | 2 | ▶ | die unless _valid_method($to_data->{options}{method}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | 2 | $new_request->{method} = uc $to_data->{options}{method}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | 16 | $new_request->{params} = $new_params; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | 16 | $new_request->{_body_params} = $request->{_body_params}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | 16 | $new_request->{_query_params} = $request->{_query_params}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | 16 | $new_request->{_route_params} = $request->{_route_params}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | 16 | $new_request->{_params_are_decoded} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | 16 | $new_request->{headers} = $request->headers; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | 16 | ▶ | if( my $session = Dancer::Session->engine | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
'Dancer::Session'->engine && 'Dancer::Session'->get_current_session
MC/DC50%1/2
'Dancer::Session'->engine && 'Dancer::Session'->get_current_session
'Dancer::Session'->engine
'Dancer::Session'->get_current_session
Truth table66%2/3
A && B
A= 'Dancer::Session'->engineB= 'Dancer::Session'->get_current_session
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | && Dancer::Session->get_current_session ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | 15 | my $name = $session->session_name; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | # make sure that COOKIE is populated | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | 15 | ▶ | $new_request->{env}{COOKIE} ||= $new_request->{env}{HTTP_COOKIE}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$new_request->{"env"}{"COOKIE"} ||= $new_request->{"env"}{"HTTP_COOKIE"}
MC/DC0%0/2
$new_request->{"env"}{"COOKIE"} ||= $new_request->{"env"}{"HTTP_COOKIE"}
$new_request->{"env"}{"COOKIE"}
$new_request->{"env"}{"HTTP_COOKIE"}
Truth table33%1/3
A ||= B
A= $new_request->{"env"}{"COOKIE"}B= $new_request->{"env"}{"HTTP_COOKIE"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | 207 | ▶ | no warnings; # COOKIE can be undef | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | 15 | ▶ | unless ( $new_request->{env}{COOKIE} =~ /$name\s*=/ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | $new_request->{env}{COOKIE} = join ';', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | 30 | grep { $_ } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | $new_request->{env}{COOKIE}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | 15 | join '=', $name, Dancer::Session->get_current_session->id; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | 16 | $new_request->{uploads} = $request->uploads; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | 16 | return $new_request; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | 2 | ▶ | sub _valid_method { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_valid_method: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | 2 | my $method = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | 2 | return $method =~ /^(?:head|post|get|put|delete)$/i; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | 16 | ▶ | sub _merge_params { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_merge_params: called CC=3 SCAR=11.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | 16 | my ($params, $to_add) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | 16 | ▶ | die unless ref $to_add eq "HASH"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | 16 | for my $key (keys %$to_add) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | 4 | $params->{$key} = $to_add->{$key}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | 16 | return $params; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | 29 | ▶ | sub base { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
base: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | 29 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | 29 | my $uri = $self->_common_uri; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | 29 | return $uri->canonical; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | 32 | ▶ | sub _common_uri { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_common_uri: called CC=8 SCAR=20.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | 32 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | 32 | ▶ | my $path = $self->env->{SCRIPT_NAME} || ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$self->env->{'SCRIPT_NAME'} || ''
MC/DC100%1/1
$self->env->{'SCRIPT_NAME'} || ''
$self->env->{'SCRIPT_NAME'}
Truth table100%2/2
A
A= $self->env->{'SCRIPT_NAME'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | 32 | my $port = $self->env->{SERVER_PORT}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | 32 | my $server = $self->env->{SERVER_NAME}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | 32 | my $host = $self->host; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | 32 | my $scheme = $self->scheme; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | 32 | my $uri = URI->new; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | 32 | $uri->scheme($scheme); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | 32 | ▶ | $uri->authority($host || "$server:$port"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$host || "${server}:$port"
MC/DC100%1/1
$host || "${server}:$port"
$host
Truth table100%2/2
A
A= $host
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | 32 | ▶ | if (setting('behind_proxy')) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | 5 | ▶ | my $request_base = $self->env->{REQUEST_BASE} || $self->env->{HTTP_REQUEST_BASE} || ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition80%4/5
$self->env->{'REQUEST_BASE'} || $self->env->{'HTTP_REQUEST_BASE'} || ''
$self->env->{"REQUEST_BASE"} or $self->env->{"HTTP_REQUEST_BASE"}
MC/DC50%1/2
$self->env->{'REQUEST_BASE'} || $self->env->{'HTTP_REQUEST_BASE'} || ''
$self->env->{"REQUEST_BASE"}
$self->env->{"HTTP_REQUEST_BASE"}
Truth table66%2/3
A or B
A= $self->env->{"REQUEST_BASE"}B= $self->env->{"HTTP_REQUEST_BASE"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | 5 | ▶ | $uri->path($request_base . $path || '/'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$request_base . $path || '/'
MC/DC100%1/1
$request_base . $path || '/'
$request_base . $path
Truth table100%2/2
A
A= $request_base . $path
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | 27 | ▶ | $uri->path($path || '/'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$path || '/'
MC/DC100%1/1
$path || '/'
$path
Truth table100%2/2
A
A= $path
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | 32 | return $uri; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | 3 | ▶ | sub uri_base { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
uri_base: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | 3 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | 3 | my $uri = $self->_common_uri; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | 3 | my $canon = $uri->canonical; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | 3 | ▶ | if ( $uri->path eq '/' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | 2 | $canon =~ s{/$}{}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | 3 | return $canon; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | 26 | ▶ | sub uri_for { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
uri_for: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | 26 | my ($self, $part, $params, $dont_escape) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | 26 | my $uri = $self->base; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | # Make sure there's exactly one slash between the base and the new part | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | 26 | my $base = $uri->path; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | 26 | $base =~ s|/$||; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | 26 | $part =~ s|^/||; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | 26 | $uri->path("$base/$part"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | 26 | ▶ | $uri->query_form($params) if $params; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | 26 | ▶ | return $dont_escape ? uri_unescape($uri->canonical) : $uri->canonical; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 309 | 436 | ▶ | sub params { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
params: called CC=11 SCAR=26.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 310 | 436 | my ($self, $source) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 311 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 312 | 436 | my @caller = caller; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 313 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 314 | 436 | ▶ | if (not $self->{_params_are_decoded}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 315 | 289 | $self->{params} = _decode($self->{params}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 316 | 289 | $self->{_body_params} = _decode($self->{_body_params}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 317 | 289 | $self->{_query_params} = _decode($self->{_query_params}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 318 | 289 | $self->{_route_params} = _decode($self->{_route_params}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 319 | 289 | $self->{_params_are_decoded} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 320 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 321 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 322 | 436 | ▶ | return %{$self->{params}} if wantarray && @_ == 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
wantarray and @_ == 1
MC/DC100%2/2
wantarray and @_ == 1
wantarray
@_ == 1
Truth table100%3/3
A and B
A= wantarrayB= @_ == 1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 323 | 421 | ▶ | return $self->{params} if @_ == 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 324 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 325 | 19 | ▶ | if ($source eq 'query') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 326 | 4 | ▶ | return %{$self->{_query_params}} if wantarray; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 327 | 2 | return $self->{_query_params}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 328 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 329 | elsif ($source eq 'body') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 330 | 0 | ▶ | return %{$self->{_body_params}} if wantarray; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 331 | 15 | return $self->{_body_params}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 332 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 333 | 0 | ▶ | if ($source eq 'route') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 334 | 0 | ▶ | return %{$self->{_route_params}} if wantarray; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 335 | 0 | return $self->{_route_params}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 336 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 337 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 338 | 0 | raise core_request => "Unknown source params \"$source\"."; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 339 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 340 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 341 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 342 | 2542 | ▶ | sub _decode { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_decode: called CC=7 SCAR=19.5
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 343 | 2542 | my ($h) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 344 | 2542 | ▶ | return if not defined $h; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 345 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 346 | 2530 | ▶ | if (!ref($h) && !utf8::is_utf8($h)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
ref $h or utf8::is_utf8($h)
MC/DC100%2/2
ref $h or utf8::is_utf8($h)
ref $h
utf8::is_utf8($h)
Truth table100%3/3
A or B
A= ref $hB= utf8::is_utf8($h)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 347 | 622 | return decode('UTF-8', $h); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 348 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 349 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 350 | 1908 | ▶ | if (ref($h) eq 'HASH') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 351 | 1797 | ▶ | while (my ($k, $v) = each(%$h)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 352 | 631 | $h->{$k} = _decode($v); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 353 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 354 | 1797 | return $h; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 355 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 356 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 357 | 111 | ▶ | if (ref($h) eq 'ARRAY') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 358 | 83 | return [ map { _decode($_) } @$h ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 359 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 360 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 361 | 28 | return $h; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 362 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 363 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 364 | 618 | ▶ | sub is_ajax { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_ajax: called CC=6 SCAR=18.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 365 | 618 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 366 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 367 | # when using Plack::Builder headers are not set | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 368 | # so we're checking if it's actually there with PSGI plain headers | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 369 | 618 | ▶ | if ( defined $self->{x_requested_with} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 370 | 2 | ▶ | if ( $self->{x_requested_with} eq "XMLHttpRequest" ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 371 | 2 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 372 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 373 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 374 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 375 | 616 | ▶ | return 0 unless defined $self->headers; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 376 | 4 | ▶ | return 0 unless defined $self->header('X-Requested-With'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 377 | 1 | ▶ | return 0 if $self->header('X-Requested-With') ne 'XMLHttpRequest'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 378 | 1 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 379 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 380 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 381 | # context-aware accessor for uploads | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 382 | 8 | ▶ | sub upload { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
upload: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 383 | 8 | my ($self, $name) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 384 | 8 | my $res = $self->{uploads}{$name}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 385 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 386 | 8 | ▶ | return $res unless wantarray; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 387 | 3 | ▶ | return () unless defined $res; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 388 | 2 | ▶ | return (ref($res) eq 'ARRAY') ? @$res : $res; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 389 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 390 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 391 | # Some Dancer's core components sometimes need to alter | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 392 | # the parsed request params, these protected accessors are provided | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 393 | # for this purpose | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 394 | 651 | ▶ | sub _set_route_params { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_set_route_params: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 395 | 651 | my ($self, $params) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 396 | 651 | $self->{_route_params} = $params; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 397 | 651 | $self->_build_params(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 398 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 399 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 400 | 8 | ▶ | sub _set_body_params { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_set_body_params: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 401 | 8 | my ($self, $params) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 402 | 8 | $self->{_body_params} = $params; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 403 | 8 | $self->_build_params(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 404 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 405 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 406 | 0 | ▶ | sub _set_query_params { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_set_query_params: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 407 | 0 | my ($self, $params) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 408 | 0 | $self->{_query_params} = $params; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 409 | 0 | $self->_build_params(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 410 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 411 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 412 | 615 | ▶ | sub _build_request_env { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_build_request_env: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 413 | 615 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 414 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 415 | # Don't refactor that, it's called whenever a request object is needed, that | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 416 | # means at least once per request. If refactored in a loop, this will cost 4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 417 | # times more than the following static map. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 418 | 615 | my $env = $self->env; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 419 | 615 | $self->{user_agent} = $env->{HTTP_USER_AGENT}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 420 | 615 | $self->{host} = $env->{HTTP_HOST}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 421 | 615 | $self->{accept_language} = $env->{HTTP_ACCEPT_LANGUAGE}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 422 | 615 | $self->{accept_charset} = $env->{HTTP_ACCEPT_CHARSET}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 423 | 615 | $self->{accept_encoding} = $env->{HTTP_ACCEPT_ENCODING}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 424 | 615 | $self->{keep_alive} = $env->{HTTP_KEEP_ALIVE}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 425 | 615 | $self->{connection} = $env->{HTTP_CONNECTION}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 426 | 615 | $self->{accept} = $env->{HTTP_ACCEPT}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 427 | 615 | $self->{accept_type} = $env->{HTTP_ACCEPT_TYPE}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 428 | 615 | $self->{referer} = $env->{HTTP_REFERER}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 429 | 615 | $self->{x_requested_with} = $env->{HTTP_X_REQUESTED_WITH}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 430 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 431 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 432 | 615 | ▶ | sub _build_headers { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_build_headers: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 433 | 615 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 434 | 615 | $self->{headers} = Dancer::SharedData->headers; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 435 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 436 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 437 | 2460 | ▶ | sub _build_params { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_build_params: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 438 | 2460 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 439 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 440 | # params may have been populated by before filters | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 441 | # _before_ we get there, so we have to save it first | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 442 | 2460 | my $previous = $self->{params}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 443 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 444 | # now parse environment params... | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 445 | 2460 | $self->_parse_get_params(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 446 | 2460 | ▶ | if ($self->is_forward) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 447 | 47 | ▶ | $self->{_body_params} ||= {}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$self->{"_body_params"} ||= {}
MC/DC100%1/1
$self->{"_body_params"} ||= {}
$self->{"_body_params"}
Truth table100%2/2
A
A= $self->{"_body_params"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 448 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 449 | 2413 | $self->_parse_post_params(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 450 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 451 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 452 | # and merge everything | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 453 | $self->{params} = { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 454 | 2460 | %$previous, %{$self->{_query_params}}, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 455 | 2460 | %{$self->{_route_params}}, %{$self->{_body_params}}, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 456 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 457 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 458 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 459 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 460 | # Written from PSGI specs: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 461 | # http://search.cpan.org/dist/PSGI/PSGI.pod | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 462 | 615 | ▶ | sub _build_path { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_build_path: called CC=6 SCAR=18.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 463 | 615 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 464 | 615 | my $path = ""; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 465 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 466 | 615 | ▶ | $path .= $self->script_name if defined $self->script_name; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 467 | 615 | ▶ | $path .= $self->env->{PATH_INFO} if defined $self->env->{PATH_INFO}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 468 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 469 | # fallback to REQUEST_URI if nothing found | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 470 | # we have to decode it, according to PSGI specs. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 471 | 615 | ▶ | if (defined $self->request_uri) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 472 | 530 | ▶ | $path ||= $self->_url_decode($self->request_uri); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$path ||= $self->_url_decode($self->request_uri)
MC/DC0%0/2
$path ||= $self->_url_decode($self->request_uri)
$path
$self->_url_decode($self->request_uri)
Truth table66%2/3
A ||= B
A= $pathB= $self->_url_decode($self->request_uri)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 473 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 474 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 475 | 615 | ▶ | raise core_request => "Cannot resolve path" if not $path; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 476 | 615 | $self->{path} = $path; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 477 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 478 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 479 | 615 | ▶ | sub _build_path_info { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_build_path_info: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 480 | 615 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 481 | 615 | my $info = $self->env->{PATH_INFO}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 482 | 615 | ▶ | if (defined $info) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 483 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 484 | # Empty path info will be interpreted as "root". | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 485 | 604 | ▶ | $info ||= '/'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$info ||= "/"
MC/DC0%0/1
$info ||= "/"
$info
Truth table50%1/2
A
A= $info
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 486 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 487 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 488 | 11 | $info = $self->path; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 489 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 490 | 615 | $self->{path_info} = $info; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 491 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 492 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 493 | 615 | ▶ | sub _build_method { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_build_method: called CC=2 SCAR=8.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 494 | 615 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 495 | $self->{method} = $self->env->{REQUEST_METHOD} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 496 | 615 | ▶ | || $self->{request}->request_method(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$self->env->{'REQUEST_METHOD'} || $self->{'request'}->request_method
MC/DC0%0/2
$self->env->{'REQUEST_METHOD'} || $self->{'request'}->request_method
$self->env->{'REQUEST_METHOD'}
$self->{'request'}->request_method
Truth table33%1/3
A || B
A= $self->env->{'REQUEST_METHOD'}B= $self->{'request'}->request_method
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 497 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 498 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 499 | 92 | ▶ | sub _url_decode { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_url_decode: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 500 | 92 | my ($self, $encoded) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 501 | 92 | my $clean = $encoded; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 502 | 92 | $clean =~ tr/\+/ /; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 503 | 92 | $clean =~ s/%([a-fA-F0-9]{2})/pack "H2", $1/eg; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 504 | 92 | return $clean; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 505 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 506 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 507 | 2413 | ▶ | sub _parse_post_params { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_parse_post_params: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 508 | 2413 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 509 | 2413 | ▶ | return $self->{_body_params} if defined $self->{_body_params}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 510 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 511 | 599 | $self->_read_to_end(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 512 | 599 | $self->{_body_params} = $self->{_http_body}->param; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 513 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 514 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 515 | 2460 | ▶ | sub _parse_get_params { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_parse_get_params: called CC=9 SCAR=22.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 516 | 2460 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 517 | 2460 | ▶ | return $self->{_query_params} if defined $self->{_query_params}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 518 | 615 | $self->{_query_params} = {}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 519 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 520 | 615 | ▶ | my $source = $self->env->{QUERY_STRING} || ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$self->env->{'QUERY_STRING'} || ''
MC/DC100%1/1
$self->env->{'QUERY_STRING'} || ''
$self->env->{'QUERY_STRING'}
Truth table100%2/2
A
A= $self->env->{'QUERY_STRING'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 521 | 615 | foreach my $token (split /[&;]/, $source) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 522 | 44 | my ($key, $val) = split(/=/, $token, 2); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 523 | 44 | ▶ | next unless defined $key; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 524 | 44 | ▶ | $val = (defined $val) ? $val : ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 525 | 44 | $key = $self->_url_decode($key); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 526 | 44 | $val = $self->_url_decode($val); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 527 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 528 | # looking for multi-value params | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 529 | 44 | ▶ | if (exists $self->{_query_params}{$key}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 530 | 4 | my $prev_val = $self->{_query_params}{$key}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 531 | 4 | ▶ | if (ref($prev_val) && ref($prev_val) eq 'ARRAY') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
ref $prev_val and ref $prev_val eq "ARRAY"
MC/DC0%0/2
ref $prev_val and ref $prev_val eq "ARRAY"
ref $prev_val
ref $prev_val eq "ARRAY"
Truth table33%1/3
A and B
A= ref $prev_valB= ref $prev_val eq "ARRAY"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 532 | 0 | push @{$self->{_query_params}{$key}}, $val; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 533 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 534 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 535 | 4 | $self->{_query_params}{$key} = [$prev_val, $val]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 536 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 537 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 538 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 539 | # simple value param (first time we see it) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 540 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 541 | 40 | $self->{_query_params}{$key} = $val; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 542 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 543 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 544 | 615 | return $self->{_query_params}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 545 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 546 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 547 | 599 | ▶ | sub _read_to_end { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_read_to_end: called CC=6 SCAR=18.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 548 | 599 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 549 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 550 | 599 | ▶ | return unless $self->_has_something_to_read; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 551 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 552 | 32 | ▶ | if ( $self->content_length > 0 ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 553 | 20 | my $body = ''; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 554 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 555 | 20 | my $store_raw_body = setting('raw_request_body_in_ram'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 556 | 20 | ▶ | $store_raw_body = defined $store_raw_body ? $store_raw_body : 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 557 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 558 | 20 | ▶ | while ( my $buffer = $self->_read ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 559 | 20 | $self->{_http_body}->add($buffer); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 560 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 561 | # Only keep a copy of the raw request body in RAM if the user has | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 562 | # asked us to | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 563 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 564 | 20 | ▶ | if ($store_raw_body) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 565 | 20 | $self->{body} .= $buffer; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 566 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 567 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 568 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 569 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 570 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 571 | 32 | return $self->{_http_body}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 572 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 573 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 574 | 599 | ▶ | sub _has_something_to_read { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_has_something_to_read: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 575 | 599 | defined $_[0]->input_handle; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 576 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 577 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 578 | # taken from Miyagawa's Plack::Request::BodyParser | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 579 | 40 | ▶ | sub _read { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_read: called CC=4 SCAR=14.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 580 | 40 | my ($self,) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 581 | 40 | my $remaining = $self->content_length - $self->{_read_position}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 582 | 40 | my $maxlength = $self->{_chunk_size}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 583 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 584 | 40 | ▶ | return if ($remaining <= 0); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 585 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 586 | 20 | ▶ | my $readlen = ($remaining > $maxlength) ? $maxlength : $remaining; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 587 | 20 | my $buffer; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 588 | my $rc; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 589 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 590 | 20 | $rc = $self->input_handle->read($buffer, $readlen); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 591 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 592 | 20 | ▶ | if (defined $rc) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 593 | 20 | $self->{_read_position} += $rc; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 594 | 20 | return $buffer; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 595 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 596 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 597 | 0 | raise core_request => "Unknown error reading input: $!"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 598 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 599 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 600 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 601 | # Taken gently from Plack::Request, thanks to Plack authors. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 602 | 615 | ▶ | sub _build_uploads { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_build_uploads: called CC=6 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 603 | 615 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 604 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 605 | 615 | my $uploads = _decode($self->{_http_body}->upload); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 606 | 615 | my %uploads; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 607 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 608 | 615 | for my $name (keys %{$uploads}) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 609 | 9 | my $files = $uploads->{$name}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 610 | 9 | ▶ | $files = ref $files eq 'ARRAY' ? $files : [$files]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 611 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 612 | 9 | my @uploads; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 613 | 9 | for my $upload (@{$files}) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 614 | push( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 615 | @uploads, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 616 | Dancer::Request::Upload->new( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 617 | headers => $upload->{headers}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 618 | tempname => $upload->{tempname}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 619 | size => $upload->{size}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 620 | filename => $upload->{filename}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 621 | ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 622 | 11 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 623 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 624 | 9 | ▶ | $uploads{$name} = @uploads > 1 ? \@uploads : $uploads[0]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 625 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 626 | # support access to the filename as a normal param | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 627 | 9 | my @filenames = map { $_->{filename} } @uploads; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 628 | 9 | ▶ | $self->{_body_params}{$name} = | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 629 | @filenames > 1 ? \@filenames : $filenames[0]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 630 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 631 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 632 | 615 | $self->{uploads} = \%uploads; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 633 | 615 | $self->_build_params(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 634 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 635 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 636 | 207 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 637 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 638 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||