| 1 | package Klonk::Env 0.01; | ||||||||||||||||||||||||||||||||||||||||||
| 2 | 1 | ▶ | use Klonk::pragma; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 3 | 1 | ▶ | use Unicode::UTF8 qw(decode_utf8); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||||||||||||
| 5 | 1 | ▶ | use constant { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 6 | 1 | MAX_FORM_BODY_SIZE => 10 * 1024 * 1024, | |||||||||||||||||||||||||||||||||||||||||
| 7 | 1 | }; | |||||||||||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||||||||||||
| 9 | 0 | ▶ | fun _parse_query($query_string) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_parse_query: not called CC=6 SCAR=37.4
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 10 | 0 | my %param; | |||||||||||||||||||||||||||||||||||||||||
| 11 | 0 | for my $kv (split /&/, $query_string) { | |||||||||||||||||||||||||||||||||||||||||
| 12 | 0 | my ($k, $v) = split /=/, $kv, 2; | |||||||||||||||||||||||||||||||||||||||||
| 13 | 0 | for ($k, $v) { | |||||||||||||||||||||||||||||||||||||||||
| 14 | 0 | ▶ | defined or next; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 15 | 0 | tr/+/ /; | |||||||||||||||||||||||||||||||||||||||||
| 16 | 0 | s/%([[:xdigit:]]{2})/chr hex $1/eg; | |||||||||||||||||||||||||||||||||||||||||
| 17 | 0 | $_ = decode_utf8 $_; | |||||||||||||||||||||||||||||||||||||||||
| 18 | } | ||||||||||||||||||||||||||||||||||||||||||
| 19 | 0 | $param{$k} = $v; | |||||||||||||||||||||||||||||||||||||||||
| 20 | } | ||||||||||||||||||||||||||||||||||||||||||
| 21 | 0 | \%param | |||||||||||||||||||||||||||||||||||||||||
| 22 | 1 | } | |||||||||||||||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||||||||||||||||
| 24 | 0 | ▶ | method new($class: $env) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: not called CC=13 SCAR=52.0
Pod
documented
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 25 | 0 | my $qparam = _parse_query $env->{QUERY_STRING}; | |||||||||||||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||||||||||||||
| 27 | 0 | my $bparam = {}; | |||||||||||||||||||||||||||||||||||||||||
| 28 | { | ||||||||||||||||||||||||||||||||||||||||||
| 29 | 0 | my $verb = $env->{REQUEST_METHOD}; | |||||||||||||||||||||||||||||||||||||||||
| 30 | 0 | ▶ | if ($verb eq 'POST' || $verb eq 'PUT' || $verb eq 'PATCH') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
$verb eq "POST" or $verb eq "PUT" or $verb eq "PATCH"
$verb eq "POST" or $verb eq "PUT"
MC/DC0%0/3
$verb eq "POST" or $verb eq "PUT" or $verb eq "PATCH"
$verb eq "POST"
$verb eq "PUT"
$verb eq "PATCH"
Truth table0%0/4
A or B or C
A= $verb eq "POST"B= $verb eq "PUT"C= $verb eq "PATCH"
| |||||||||||||||||||||||||||||||||||||||||||
| 31 | 0 | ▶ | my $ctype = $env->{CONTENT_TYPE} // ''; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$env->{"CONTENT_TYPE"} // ""
MC/DC0%0/1
$env->{"CONTENT_TYPE"} // ""
$env->{"CONTENT_TYPE"}
Truth table0%0/2
A
A= $env->{"CONTENT_TYPE"}
| |||||||||||||||||||||||||||||||||||||||||||
| 32 | 0 | ▶ | my $clength = $env->{CONTENT_LENGTH} // 0; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$env->{"CONTENT_LENGTH"} // 0
MC/DC0%0/1
$env->{"CONTENT_LENGTH"} // 0
$env->{"CONTENT_LENGTH"}
Truth table0%0/2
A
A= $env->{"CONTENT_LENGTH"}
| |||||||||||||||||||||||||||||||||||||||||||
| 33 | 0 | ▶ | $clength <= MAX_FORM_BODY_SIZE | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 34 | or die "Request size ($clength) exceeds maximum form size"; | ||||||||||||||||||||||||||||||||||||||||||
| 35 | 0 | ▶ | if ($ctype eq 'application/x-www-form-urlencoded') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 36 | 0 | my $input = $env->{'psgi.input'}; | |||||||||||||||||||||||||||||||||||||||||
| 37 | 0 | my $query = ''; | |||||||||||||||||||||||||||||||||||||||||
| 38 | 0 | ▶ | while ((my $d = $clength - length($query)) > 0) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 39 | 0 | ▶ | my $n = $input->read($query, $d, length($query)) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 40 | and next; | ||||||||||||||||||||||||||||||||||||||||||
| 41 | 0 | ▶ | defined $n | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 42 | 0 | and die "Premature end of request body (received ${\length $query} of $clength bytes)"; | |||||||||||||||||||||||||||||||||||||||||
| 43 | 0 | die "Error while reading request body: $!"; | |||||||||||||||||||||||||||||||||||||||||
| 44 | } | ||||||||||||||||||||||||||||||||||||||||||
| 45 | 0 | $bparam = _parse_query $query; | |||||||||||||||||||||||||||||||||||||||||
| 46 | } | ||||||||||||||||||||||||||||||||||||||||||
| 47 | } | ||||||||||||||||||||||||||||||||||||||||||
| 48 | } | ||||||||||||||||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||||||||||||||||
| 50 | bless { | ||||||||||||||||||||||||||||||||||||||||||
| 51 | 0 | %$env, | |||||||||||||||||||||||||||||||||||||||||
| 52 | 'klonk.qparam' => $qparam, | ||||||||||||||||||||||||||||||||||||||||||
| 53 | 'klonk.bparam' => $bparam, | ||||||||||||||||||||||||||||||||||||||||||
| 54 | }, $class | ||||||||||||||||||||||||||||||||||||||||||
| 55 | 1 | } | |||||||||||||||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||||||||||||||||
| 57 | 0 | ▶ | method DESTROY(@) {} | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
DESTROY: not called CC=2 SCAR=14.6
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||||||||||||||||
| 59 | 0 | ▶ | method vpath($path) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
vpath: not called CC=3 SCAR=24.8
Pod
documented
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 60 | 0 | $self->{SCRIPT_NAME} . '/' . $path =~ s!^/!!r | |||||||||||||||||||||||||||||||||||||||||
| 61 | 1 | } | |||||||||||||||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||||||||||||||||
| 63 | 0 | ▶ | method qparam($k) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
qparam: not called CC=3 SCAR=24.8
Pod
documented
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 64 | 0 | $self->{'klonk.qparam'}{$k} | |||||||||||||||||||||||||||||||||||||||||
| 65 | 1 | } | |||||||||||||||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||||||||||||||||
| 67 | 0 | ▶ | method bparam($k) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
bparam: not called CC=3 SCAR=24.8
Pod
documented
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 68 | 0 | $self->{'klonk.bparam'}{$k} | |||||||||||||||||||||||||||||||||||||||||
| 69 | 1 | } | |||||||||||||||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||||||||||||||||
| 71 | 1 | 1 | |||||||||||||||||||||||||||||||||||||||||
| 72 | __END__ | ||||||||||||||||||||||||||||||||||||||||||