| 1 | package Linux::Event::HTTP::Request; | ||||||||||||||||||||||||||||||||||||||||||
| 2 | 42 | ▶ | use v5.36; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 3 | 42 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 4 | 42 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||||||||||||||||
| 6 | 42 | ▶ | use Hash::Util::FieldHash qw(fieldhash); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 7 | 42 | ▶ | use Scalar::Util qw(reftype); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 8 | 42 | ▶ | use utf8 (); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||||||||||||
| 10 | 42 | ▶ | use Linux::Event::HTTP::_HTTP1 (); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||||||||||||
| 12 | 42 | our $VERSION = '0.003'; | |||||||||||||||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||||||||||||||||
| 14 | my ( | ||||||||||||||||||||||||||||||||||||||||||
| 15 | 42 | $NATIVE_METHOD, | |||||||||||||||||||||||||||||||||||||||||
| 16 | $NATIVE_TARGET, | ||||||||||||||||||||||||||||||||||||||||||
| 17 | $NATIVE_VERSION, | ||||||||||||||||||||||||||||||||||||||||||
| 18 | $NATIVE_BODY_MODE, | ||||||||||||||||||||||||||||||||||||||||||
| 19 | $NATIVE_CONTENT_LENGTH, | ||||||||||||||||||||||||||||||||||||||||||
| 20 | $NATIVE_KEEP_ALIVE, | ||||||||||||||||||||||||||||||||||||||||||
| 21 | $NATIVE_HEADER_COUNT, | ||||||||||||||||||||||||||||||||||||||||||
| 22 | $NATIVE_HEADER_NAME, | ||||||||||||||||||||||||||||||||||||||||||
| 23 | $NATIVE_HEADER_VALUE, | ||||||||||||||||||||||||||||||||||||||||||
| 24 | $NATIVE_HEADER, | ||||||||||||||||||||||||||||||||||||||||||
| 25 | $NATIVE_HEADER_VALUES, | ||||||||||||||||||||||||||||||||||||||||||
| 26 | $NATIVE_DESTROY, | ||||||||||||||||||||||||||||||||||||||||||
| 27 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||||||||||||||||
| 29 | 42 | ▶ | BEGIN { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 30 | 42 | ▶ | no strict 'refs'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 31 | 42 | $NATIVE_METHOD = \&{__PACKAGE__ . '::method'}; | |||||||||||||||||||||||||||||||||||||||||
| 32 | 42 | $NATIVE_TARGET = \&{__PACKAGE__ . '::target'}; | |||||||||||||||||||||||||||||||||||||||||
| 33 | 42 | $NATIVE_VERSION = \&{__PACKAGE__ . '::http_version'}; | |||||||||||||||||||||||||||||||||||||||||
| 34 | 42 | $NATIVE_BODY_MODE = \&{__PACKAGE__ . '::body_mode'}; | |||||||||||||||||||||||||||||||||||||||||
| 35 | 42 | $NATIVE_CONTENT_LENGTH = \&{__PACKAGE__ . '::content_length'}; | |||||||||||||||||||||||||||||||||||||||||
| 36 | 42 | $NATIVE_KEEP_ALIVE = \&{__PACKAGE__ . '::keep_alive'}; | |||||||||||||||||||||||||||||||||||||||||
| 37 | 42 | $NATIVE_HEADER_COUNT = \&{__PACKAGE__ . '::header_count'}; | |||||||||||||||||||||||||||||||||||||||||
| 38 | 42 | $NATIVE_HEADER_NAME = \&{__PACKAGE__ . '::header_name'}; | |||||||||||||||||||||||||||||||||||||||||
| 39 | 42 | $NATIVE_HEADER_VALUE = \&{__PACKAGE__ . '::header_value'}; | |||||||||||||||||||||||||||||||||||||||||
| 40 | 42 | $NATIVE_HEADER = \&{__PACKAGE__ . '::header'}; | |||||||||||||||||||||||||||||||||||||||||
| 41 | 42 | $NATIVE_HEADER_VALUES = \&{__PACKAGE__ . '::header_values'}; | |||||||||||||||||||||||||||||||||||||||||
| 42 | 42 | $NATIVE_DESTROY = \&{__PACKAGE__ . '::DESTROY'}; | |||||||||||||||||||||||||||||||||||||||||
| 43 | } | ||||||||||||||||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||||||||||||||||
| 45 | 42 | ▶ | no warnings 'redefine'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||||||||||||||||
| 47 | 42 | fieldhash my %NATIVE_COMPLETE; | |||||||||||||||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||||||||||||||||
| 49 | 0 | ▶ | sub CLONE_SKIP { 1 } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
CLONE_SKIP: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||||||||||||||||
| 51 | 3214 | ▶ | sub _is_native ($self) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_is_native: called CC=2 SCAR=7.6
| |||||||||||||||||||||||||||||||||||||||||||
| 52 | 3214 | ▶ | return (reftype($self) // '') eq 'SCALAR'; | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
builtin::reftype($self) // ""
MC/DC0%0/1
builtin::reftype($self) // ""
builtin::reftype($self)
Truth table50%1/2
A
A= builtin::reftype($self)
| |||||||||||||||||||||||||||||||||||||||||||
| 53 | } | ||||||||||||||||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||||||||||||||||
| 55 | 292 | ▶ | sub _byte_string ($operation, $value) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_byte_string: called CC=5 SCAR=16.2
| |||||||||||||||||||||||||||||||||||||||||||
| 56 | 292 | ▶ | die "$operation(): value must be a defined scalar byte string" | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
not defined $value or ref $value
MC/DC50%1/2
not defined $value or ref $value
not defined $value
ref $value
Truth table66%2/3
not(A) or B
A= not defined $valueB= ref $value
| |||||||||||||||||||||||||||||||||||||||||||
| 57 | if !defined($value) || ref($value); | ||||||||||||||||||||||||||||||||||||||||||
| 58 | 291 | my $bytes = "$value"; | |||||||||||||||||||||||||||||||||||||||||
| 59 | 291 | ▶ | if (utf8::is_utf8($bytes)) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 60 | 1 | ▶ | die "$operation(): value contains wide characters; encode it to bytes first" | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 61 | if !utf8::downgrade($bytes, 1); | ||||||||||||||||||||||||||||||||||||||||||
| 62 | } | ||||||||||||||||||||||||||||||||||||||||||
| 63 | 290 | return $bytes; | |||||||||||||||||||||||||||||||||||||||||
| 64 | } | ||||||||||||||||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||||||||||||||||
| 66 | 113 | ▶ | sub _validate_method ($method) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_validate_method: called CC=5 SCAR=19.2
| |||||||||||||||||||||||||||||||||||||||||||
| 67 | 113 | ▶ | die 'request method is required' if !defined($method) || ref($method) || $method eq ''; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
not defined $method or ref $method or $method eq ""
not defined $method or ref $method
MC/DC0%0/3
not defined $method or ref $method or $method eq ""
not defined $method
ref $method
$method eq ""
Truth table25%1/4
not(A) or B or C
A= not defined $methodB= ref $methodC= $method eq ""
| |||||||||||||||||||||||||||||||||||||||||||
| 68 | 113 | ▶ | die 'invalid request method' | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 69 | if $method !~ /\A[!#\$%&'*+\-.^_`|~0-9A-Za-z]+\z/; | ||||||||||||||||||||||||||||||||||||||||||
| 70 | } | ||||||||||||||||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||||||||||||||||
| 72 | 112 | ▶ | sub _validate_target ($target) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_validate_target: called CC=5 SCAR=18.1
| |||||||||||||||||||||||||||||||||||||||||||
| 73 | 112 | ▶ | die 'request target is required' if !defined($target) || ref($target) || $target eq ''; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
not defined $target or ref $target or $target eq ""
not defined $target or ref $target
MC/DC0%0/3
not defined $target or ref $target or $target eq ""
not defined $target
ref $target
$target eq ""
Truth table25%1/4
not(A) or B or C
A= not defined $targetB= ref $targetC= $target eq ""
| |||||||||||||||||||||||||||||||||||||||||||
| 74 | 112 | my $bytes = _byte_string('target', $target); | |||||||||||||||||||||||||||||||||||||||||
| 75 | 112 | ▶ | die 'invalid request target' if $bytes =~ /[\x00-\x20\x7f]/; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 76 | 111 | return $bytes; | |||||||||||||||||||||||||||||||||||||||||
| 77 | } | ||||||||||||||||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||||||||||||||||
| 79 | 6 | ▶ | sub _validate_scheme ($scheme) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_validate_scheme: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||
| 80 | 6 | ▶ | return undef if !defined $scheme; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 81 | 5 | my $bytes = _byte_string('scheme', $scheme); | |||||||||||||||||||||||||||||||||||||||||
| 82 | 5 | ▶ | die 'invalid request scheme' | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 83 | if $bytes !~ /\A[A-Za-z][A-Za-z0-9+.-]*\z/; | ||||||||||||||||||||||||||||||||||||||||||
| 84 | 5 | return $bytes; | |||||||||||||||||||||||||||||||||||||||||
| 85 | } | ||||||||||||||||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||||||||||||||||
| 87 | 8 | ▶ | sub _validate_authority ($authority) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_validate_authority: called CC=4 SCAR=14.6
| |||||||||||||||||||||||||||||||||||||||||||
| 88 | 8 | ▶ | return undef if !defined $authority; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 89 | 7 | my $bytes = _byte_string('authority', $authority); | |||||||||||||||||||||||||||||||||||||||||
| 90 | 7 | ▶ | die 'invalid request authority' | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$bytes eq "" or $bytes =~ m[[\x00-\x20\x7f/?#]]u
MC/DC0%0/2
$bytes eq "" or $bytes =~ m[[\x00-\x20\x7f/?#]]u
$bytes eq ""
$bytes =~ m[[\x00-\x20\x7f/?#]]u
Truth table33%1/3
A or B
A= $bytes eq ""B= $bytes =~ m[[\x00-\x20\x7f/?#]]u
| |||||||||||||||||||||||||||||||||||||||||||
| 91 | if $bytes eq '' || $bytes =~ /[\x00-\x20\x7f\/?#]/; | ||||||||||||||||||||||||||||||||||||||||||
| 92 | 7 | return $bytes; | |||||||||||||||||||||||||||||||||||||||||
| 93 | } | ||||||||||||||||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||||||||||||||||
| 95 | 9 | ▶ | sub _target_metadata ($method, $target) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_target_metadata: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||||||||||||||||
| 96 | 9 | ▶ | if ($target =~ /\A([A-Za-z][A-Za-z0-9+.-]*):\/\/([^\/?#]+)/) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 97 | 2 | return ($1, $2); | |||||||||||||||||||||||||||||||||||||||||
| 98 | } | ||||||||||||||||||||||||||||||||||||||||||
| 99 | 7 | ▶ | if (uc($method) eq 'CONNECT' && $target !~ /[\/?#]/) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
uc $method eq "CONNECT" and not $target =~ m[[/?#]]u
MC/DC50%1/2
uc $method eq "CONNECT" and not $target =~ m[[/?#]]u
uc $method eq "CONNECT"
not $target =~ m[[/?#]]u
Truth table66%2/3
A and not(B)
A= uc $method eq "CONNECT"B= not $target =~ m[[/?#]]u
| |||||||||||||||||||||||||||||||||||||||||||
| 100 | 3 | return (undef, $target); | |||||||||||||||||||||||||||||||||||||||||
| 101 | } | ||||||||||||||||||||||||||||||||||||||||||
| 102 | 4 | return (undef, undef); | |||||||||||||||||||||||||||||||||||||||||
| 103 | } | ||||||||||||||||||||||||||||||||||||||||||
| 104 | |||||||||||||||||||||||||||||||||||||||||||
| 105 | 111 | ▶ | sub _validate_version ($version) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_validate_version: called CC=4 SCAR=19.1
| |||||||||||||||||||||||||||||||||||||||||||
| 106 | 111 | ▶ | die 'invalid HTTP version' | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
not defined $version or ref $version or not "$version" =~ /\A[0-9]+(?:\.[0-9]+)?\z/u
not defined $version or ref $version
MC/DC0%0/3
not defined $version or ref $version or not "$version" =~ /\A[0-9]+(?:\.[0-9]+)?\z/u
not defined $version
ref $version
not "$version" =~ /\A[0-9]+(?:\.[0-9]+)?\z/u
Truth table25%1/4
not(A) or B or not(C)
A= not defined $versionB= ref $versionC= not "$version" =~ /\A[0-9]+(?:\.[0-9]+)?\z/u
| |||||||||||||||||||||||||||||||||||||||||||
| 107 | if !defined($version) || ref($version) | ||||||||||||||||||||||||||||||||||||||||||
| 108 | || "$version" !~ /\A[0-9]+(?:\.[0-9]+)?\z/; | ||||||||||||||||||||||||||||||||||||||||||
| 109 | } | ||||||||||||||||||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||||||||||||||||
| 111 | 584 | ▶ | sub _validate_name ($name) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_validate_name: called CC=5 SCAR=19.2
| |||||||||||||||||||||||||||||||||||||||||||
| 112 | 584 | ▶ | die 'header field name is required' if !defined($name) || ref($name) || $name eq ''; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
not defined $name or ref $name or $name eq ""
not defined $name or ref $name
MC/DC0%0/3
not defined $name or ref $name or $name eq ""
not defined $name
ref $name
$name eq ""
Truth table25%1/4
not(A) or B or C
A= not defined $nameB= ref $nameC= $name eq ""
| |||||||||||||||||||||||||||||||||||||||||||
| 113 | 584 | ▶ | die 'invalid header field name' | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 114 | if $name !~ /\A[!#\$%&'*+\-.^_`|~0-9A-Za-z]+\z/; | ||||||||||||||||||||||||||||||||||||||||||
| 115 | } | ||||||||||||||||||||||||||||||||||||||||||
| 116 | |||||||||||||||||||||||||||||||||||||||||||
| 117 | 155 | ▶ | sub _validate_value ($value) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_validate_value: called CC=4 SCAR=15.6
| |||||||||||||||||||||||||||||||||||||||||||
| 118 | 155 | ▶ | die 'header field value must be defined' if !defined($value) || ref($value); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
not defined $value or ref $value
MC/DC0%0/2
not defined $value or ref $value
not defined $value
ref $value
Truth table33%1/3
not(A) or B
A= not defined $valueB= ref $value
| |||||||||||||||||||||||||||||||||||||||||||
| 119 | 155 | my $bytes = _byte_string('header', $value); | |||||||||||||||||||||||||||||||||||||||||
| 120 | 155 | ▶ | die 'header field value contains invalid control characters' | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 121 | if $bytes =~ /[\x00-\x08\x0a-\x1f\x7f]/; | ||||||||||||||||||||||||||||||||||||||||||
| 122 | 155 | return $bytes; | |||||||||||||||||||||||||||||||||||||||||
| 123 | } | ||||||||||||||||||||||||||||||||||||||||||
| 124 | |||||||||||||||||||||||||||||||||||||||||||
| 125 | 268 | ▶ | sub _validate_header_index ($index) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_validate_header_index: called CC=4 SCAR=14.9
| |||||||||||||||||||||||||||||||||||||||||||
| 126 | 268 | ▶ | die 'header index must be a non-negative integer' | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%3/6
not defined $index or ref $index or not "$index" =~ /\A[0-9]+\z/u
not defined $index or ref $index
MC/DC33%1/3
not defined $index or ref $index or not "$index" =~ /\A[0-9]+\z/u
not defined $index
ref $index
not "$index" =~ /\A[0-9]+\z/u
Truth table50%2/4
not(A) or B or not(C)
A= not defined $indexB= ref $indexC= not "$index" =~ /\A[0-9]+\z/u
| |||||||||||||||||||||||||||||||||||||||||||
| 127 | if !defined($index) || ref($index) || "$index" !~ /\A[0-9]+\z/; | ||||||||||||||||||||||||||||||||||||||||||
| 128 | 264 | return 0 + $index; | |||||||||||||||||||||||||||||||||||||||||
| 129 | } | ||||||||||||||||||||||||||||||||||||||||||
| 130 | |||||||||||||||||||||||||||||||||||||||||||
| 131 | 187 | ▶ | sub _assert_mutable ($self) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_assert_mutable: called CC=3 SCAR=11.1
| |||||||||||||||||||||||||||||||||||||||||||
| 132 | 187 | ▶ | die 'received request metadata is read-only' if _is_native($self); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 133 | die 'request metadata cannot change after the message is committed' | ||||||||||||||||||||||||||||||||||||||||||
| 134 | 187 | ▶ | if $self->{committed}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 135 | } | ||||||||||||||||||||||||||||||||||||||||||
| 136 | |||||||||||||||||||||||||||||||||||||||||||
| 137 | 112 | ▶ | sub new ($class, %args) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=13 SCAR=25.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 138 | 112 | my $method = delete $args{method}; | |||||||||||||||||||||||||||||||||||||||||
| 139 | 112 | my $target = delete $args{target}; | |||||||||||||||||||||||||||||||||||||||||
| 140 | 112 | ▶ | my $version = delete($args{version}) // '1.1'; | ||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
delete $args{"version"} // "1.1"
MC/DC100%1/1
delete $args{"version"} // "1.1"
delete $args{"version"}
Truth table100%2/2
A
A= delete $args{"version"}
| |||||||||||||||||||||||||||||||||||||||||||
| 141 | 112 | my $has_scheme = exists $args{scheme}; | |||||||||||||||||||||||||||||||||||||||||
| 142 | 112 | my $scheme = delete $args{scheme}; | |||||||||||||||||||||||||||||||||||||||||
| 143 | 112 | my $has_authority = exists $args{authority}; | |||||||||||||||||||||||||||||||||||||||||
| 144 | 112 | my $authority = delete $args{authority}; | |||||||||||||||||||||||||||||||||||||||||
| 145 | 112 | my $headers = delete $args{headers}; | |||||||||||||||||||||||||||||||||||||||||
| 146 | 112 | my $has_body = exists $args{body}; | |||||||||||||||||||||||||||||||||||||||||
| 147 | 112 | my $body = delete $args{body}; | |||||||||||||||||||||||||||||||||||||||||
| 148 | |||||||||||||||||||||||||||||||||||||||||||
| 149 | 112 | ▶ | die 'unknown request option: ' . join(', ', sort keys %args) if %args; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 150 | |||||||||||||||||||||||||||||||||||||||||||
| 151 | 112 | _validate_method($method); | |||||||||||||||||||||||||||||||||||||||||
| 152 | 111 | $target = _validate_target($target); | |||||||||||||||||||||||||||||||||||||||||
| 153 | 110 | _validate_version($version); | |||||||||||||||||||||||||||||||||||||||||
| 154 | 110 | ▶ | $scheme = _validate_scheme($scheme) if $has_scheme; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 155 | 110 | ▶ | $authority = _validate_authority($authority) if $has_authority; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 156 | |||||||||||||||||||||||||||||||||||||||||||
| 157 | 110 | ▶ | my $self = bless { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 158 | method => "$method", | ||||||||||||||||||||||||||||||||||||||||||
| 159 | target => $target, | ||||||||||||||||||||||||||||||||||||||||||
| 160 | version => "$version", | ||||||||||||||||||||||||||||||||||||||||||
| 161 | ($has_scheme ? (scheme => $scheme) : ()), | ||||||||||||||||||||||||||||||||||||||||||
| 162 | ($has_authority ? (authority => $authority) : ()), | ||||||||||||||||||||||||||||||||||||||||||
| 163 | headers => [], | ||||||||||||||||||||||||||||||||||||||||||
| 164 | body_kind => undef, | ||||||||||||||||||||||||||||||||||||||||||
| 165 | body => undef, | ||||||||||||||||||||||||||||||||||||||||||
| 166 | committed => 0, | ||||||||||||||||||||||||||||||||||||||||||
| 167 | complete => 1, | ||||||||||||||||||||||||||||||||||||||||||
| 168 | }, $class; | ||||||||||||||||||||||||||||||||||||||||||
| 169 | |||||||||||||||||||||||||||||||||||||||||||
| 170 | 110 | ▶ | if (defined $headers) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 171 | 94 | ▶ | die 'headers must be an array reference of [name, value] pairs' | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 172 | if ref($headers) ne 'ARRAY'; | ||||||||||||||||||||||||||||||||||||||||||
| 173 | 94 | for my $pair (@$headers) { | |||||||||||||||||||||||||||||||||||||||||
| 174 | 142 | ▶ | die 'each request header must be a [name, value] pair' | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
ref $pair ne "ARRAY" or @$pair != 2
MC/DC0%0/2
ref $pair ne "ARRAY" or @$pair != 2
ref $pair ne "ARRAY"
@$pair != 2
Truth table33%1/3
A or B
A= ref $pair ne "ARRAY"B= @$pair != 2
| |||||||||||||||||||||||||||||||||||||||||||
| 175 | if ref($pair) ne 'ARRAY' || @$pair != 2; | ||||||||||||||||||||||||||||||||||||||||||
| 176 | 142 | $self->add_header($pair->[0], $pair->[1]); | |||||||||||||||||||||||||||||||||||||||||
| 177 | } | ||||||||||||||||||||||||||||||||||||||||||
| 178 | } | ||||||||||||||||||||||||||||||||||||||||||
| 179 | |||||||||||||||||||||||||||||||||||||||||||
| 180 | 109 | ▶ | $self->body($body) if $has_body; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 181 | 108 | return $self; | |||||||||||||||||||||||||||||||||||||||||
| 182 | } | ||||||||||||||||||||||||||||||||||||||||||
| 183 | |||||||||||||||||||||||||||||||||||||||||||
| 184 | 406 | ▶ | sub method ($self, @args) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
method: called CC=5 SCAR=16.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 185 | 406 | ▶ | if (_is_native($self)) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 186 | 75 | ▶ | die 'received request metadata is read-only' if @args; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 187 | 74 | return $NATIVE_METHOD->($self); | |||||||||||||||||||||||||||||||||||||||||
| 188 | } | ||||||||||||||||||||||||||||||||||||||||||
| 189 | 331 | ▶ | return $self->{method} if !@args; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 190 | 1 | ▶ | die 'method accepts exactly one value' if @args != 1; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 191 | 1 | $self->_assert_mutable; | |||||||||||||||||||||||||||||||||||||||||
| 192 | 1 | _validate_method($args[0]); | |||||||||||||||||||||||||||||||||||||||||
| 193 | 1 | $self->{method} = "$args[0]"; | |||||||||||||||||||||||||||||||||||||||||
| 194 | 1 | return $self; | |||||||||||||||||||||||||||||||||||||||||
| 195 | } | ||||||||||||||||||||||||||||||||||||||||||
| 196 | |||||||||||||||||||||||||||||||||||||||||||
| 197 | 450 | ▶ | sub target ($self, @args) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
target: called CC=5 SCAR=16.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 198 | 450 | ▶ | if (_is_native($self)) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 199 | 338 | ▶ | die 'received request metadata is read-only' if @args; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 200 | 338 | return $NATIVE_TARGET->($self); | |||||||||||||||||||||||||||||||||||||||||
| 201 | } | ||||||||||||||||||||||||||||||||||||||||||
| 202 | 112 | ▶ | return $self->{target} if !@args; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 203 | 2 | ▶ | die 'target accepts exactly one value' if @args != 1; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 204 | 2 | $self->_assert_mutable; | |||||||||||||||||||||||||||||||||||||||||
| 205 | 1 | $self->{target} = _validate_target($args[0]); | |||||||||||||||||||||||||||||||||||||||||
| 206 | 1 | return $self; | |||||||||||||||||||||||||||||||||||||||||
| 207 | } | ||||||||||||||||||||||||||||||||||||||||||
| 208 | |||||||||||||||||||||||||||||||||||||||||||
| 209 | 4 | ▶ | sub target_is_exact ($self) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
target_is_exact: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 210 | 4 | return 1; | |||||||||||||||||||||||||||||||||||||||||
| 211 | } | ||||||||||||||||||||||||||||||||||||||||||
| 212 | |||||||||||||||||||||||||||||||||||||||||||
| 213 | 12 | ▶ | sub scheme ($self, @args) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
scheme: called CC=6 SCAR=18.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 214 | 12 | ▶ | if (@args) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 215 | 2 | ▶ | die 'scheme accepts exactly one value' if @args != 1; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 216 | 2 | ▶ | die 'received request metadata is read-only' if _is_native($self); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 217 | 2 | $self->_assert_mutable; | |||||||||||||||||||||||||||||||||||||||||
| 218 | 2 | $self->{scheme} = _validate_scheme($args[0]); | |||||||||||||||||||||||||||||||||||||||||
| 219 | 2 | return $self; | |||||||||||||||||||||||||||||||||||||||||
| 220 | } | ||||||||||||||||||||||||||||||||||||||||||
| 221 | |||||||||||||||||||||||||||||||||||||||||||
| 222 | 10 | ▶ | if (!_is_native($self) && exists $self->{scheme}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
not _is_native($self) and exists $self->{"scheme"}
MC/DC100%2/2
not _is_native($self) and exists $self->{"scheme"}
not _is_native($self)
exists $self->{"scheme"}
Truth table100%3/3
not(A) and B
A= not _is_native($self)B= exists $self->{"scheme"}
| |||||||||||||||||||||||||||||||||||||||||||
| 223 | 5 | return $self->{scheme}; | |||||||||||||||||||||||||||||||||||||||||
| 224 | } | ||||||||||||||||||||||||||||||||||||||||||
| 225 | 5 | my ($scheme) = _target_metadata($self->method, $self->target); | |||||||||||||||||||||||||||||||||||||||||
| 226 | 5 | return $scheme; | |||||||||||||||||||||||||||||||||||||||||
| 227 | } | ||||||||||||||||||||||||||||||||||||||||||
| 228 | |||||||||||||||||||||||||||||||||||||||||||
| 229 | 14 | ▶ | sub authority ($self, @args) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
authority: called CC=8 SCAR=21.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 230 | 14 | ▶ | if (@args) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 231 | 2 | ▶ | die 'authority accepts exactly one value' if @args != 1; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 232 | 2 | ▶ | die 'received request metadata is read-only' if _is_native($self); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 233 | 2 | $self->_assert_mutable; | |||||||||||||||||||||||||||||||||||||||||
| 234 | 2 | $self->{authority} = _validate_authority($args[0]); | |||||||||||||||||||||||||||||||||||||||||
| 235 | 2 | return $self; | |||||||||||||||||||||||||||||||||||||||||
| 236 | } | ||||||||||||||||||||||||||||||||||||||||||
| 237 | |||||||||||||||||||||||||||||||||||||||||||
| 238 | 12 | ▶ | if (!_is_native($self) && exists $self->{authority}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
not _is_native($self) and exists $self->{"authority"}
MC/DC100%2/2
not _is_native($self) and exists $self->{"authority"}
not _is_native($self)
exists $self->{"authority"}
Truth table100%3/3
not(A) and B
A= not _is_native($self)B= exists $self->{"authority"}
| |||||||||||||||||||||||||||||||||||||||||||
| 239 | 8 | return $self->{authority}; | |||||||||||||||||||||||||||||||||||||||||
| 240 | } | ||||||||||||||||||||||||||||||||||||||||||
| 241 | |||||||||||||||||||||||||||||||||||||||||||
| 242 | 4 | my (undef, $authority) = _target_metadata($self->method, $self->target); | |||||||||||||||||||||||||||||||||||||||||
| 243 | 4 | ▶ | return $authority if defined $authority; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 244 | |||||||||||||||||||||||||||||||||||||||||||
| 245 | 2 | my @host = $self->_header_values_list('Host'); | |||||||||||||||||||||||||||||||||||||||||
| 246 | 2 | ▶ | return $host[0] if @host == 1; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 247 | 0 | return undef; | |||||||||||||||||||||||||||||||||||||||||
| 248 | } | ||||||||||||||||||||||||||||||||||||||||||
| 249 | |||||||||||||||||||||||||||||||||||||||||||
| 250 | 243 | ▶ | sub version ($self, @args) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
version: called CC=6 SCAR=18.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 251 | 243 | ▶ | if (_is_native($self)) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 252 | 66 | ▶ | die 'received request metadata is read-only' if @args; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 253 | 66 | return $NATIVE_VERSION->($self); | |||||||||||||||||||||||||||||||||||||||||
| 254 | } | ||||||||||||||||||||||||||||||||||||||||||
| 255 | 177 | ▶ | return $self->{version} if !@args; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 256 | 2 | ▶ | die 'version accepts exactly one value' if @args != 1; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 257 | 2 | $self->_assert_mutable; | |||||||||||||||||||||||||||||||||||||||||
| 258 | 2 | ▶ | if (!defined $args[0]) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 259 | 1 | $self->{version} = undef; | |||||||||||||||||||||||||||||||||||||||||
| 260 | 1 | return $self; | |||||||||||||||||||||||||||||||||||||||||
| 261 | } | ||||||||||||||||||||||||||||||||||||||||||
| 262 | 1 | _validate_version($args[0]); | |||||||||||||||||||||||||||||||||||||||||
| 263 | 1 | $self->{version} = "$args[0]"; | |||||||||||||||||||||||||||||||||||||||||
| 264 | 1 | return $self; | |||||||||||||||||||||||||||||||||||||||||
| 265 | } | ||||||||||||||||||||||||||||||||||||||||||
| 266 | |||||||||||||||||||||||||||||||||||||||||||
| 267 | 114 | ▶ | sub header ($self, $name, @args) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
header: called CC=11 SCAR=24.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 268 | 114 | _validate_name($name); | |||||||||||||||||||||||||||||||||||||||||
| 269 | 114 | ▶ | if (_is_native($self)) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 270 | 87 | ▶ | die 'received request metadata is read-only' if @args; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 271 | 86 | return $NATIVE_HEADER->($self, $name); | |||||||||||||||||||||||||||||||||||||||||
| 272 | } | ||||||||||||||||||||||||||||||||||||||||||
| 273 | |||||||||||||||||||||||||||||||||||||||||||
| 274 | 27 | ▶ | if (!@args) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 275 | 13 | my $wanted = lc $name; | |||||||||||||||||||||||||||||||||||||||||
| 276 | 13 | for my $pair (@{$self->{headers}}) { | |||||||||||||||||||||||||||||||||||||||||
| 277 | 20 | ▶ | return $pair->[1] if lc($pair->[0]) eq $wanted; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 278 | } | ||||||||||||||||||||||||||||||||||||||||||
| 279 | 2 | return undef; | |||||||||||||||||||||||||||||||||||||||||
| 280 | } | ||||||||||||||||||||||||||||||||||||||||||
| 281 | |||||||||||||||||||||||||||||||||||||||||||
| 282 | 14 | ▶ | die 'header setter accepts exactly one value' if @args != 1; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 283 | 14 | $self->_assert_mutable; | |||||||||||||||||||||||||||||||||||||||||
| 284 | 13 | my $value = _validate_value($args[0]); | |||||||||||||||||||||||||||||||||||||||||
| 285 | 13 | my $wanted = lc $name; | |||||||||||||||||||||||||||||||||||||||||
| 286 | 13 | my @headers; | |||||||||||||||||||||||||||||||||||||||||
| 287 | 13 | my $inserted = 0; | |||||||||||||||||||||||||||||||||||||||||
| 288 | 13 | for my $pair (@{$self->{headers}}) { | |||||||||||||||||||||||||||||||||||||||||
| 289 | 24 | ▶ | if (lc($pair->[0]) eq $wanted) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 290 | 4 | ▶ | if (!$inserted) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 291 | 2 | push @headers, [ "$name", $value ]; | |||||||||||||||||||||||||||||||||||||||||
| 292 | 2 | $inserted = 1; | |||||||||||||||||||||||||||||||||||||||||
| 293 | } | ||||||||||||||||||||||||||||||||||||||||||
| 294 | 4 | next; | |||||||||||||||||||||||||||||||||||||||||
| 295 | } | ||||||||||||||||||||||||||||||||||||||||||
| 296 | 20 | push @headers, [ @$pair ]; | |||||||||||||||||||||||||||||||||||||||||
| 297 | } | ||||||||||||||||||||||||||||||||||||||||||
| 298 | 13 | ▶ | push @headers, [ "$name", $value ] if !$inserted; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 299 | 13 | $self->{headers} = \@headers; | |||||||||||||||||||||||||||||||||||||||||
| 300 | 13 | return $self; | |||||||||||||||||||||||||||||||||||||||||
| 301 | } | ||||||||||||||||||||||||||||||||||||||||||
| 302 | |||||||||||||||||||||||||||||||||||||||||||
| 303 | 143 | ▶ | sub add_header ($self, $name, $value) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
add_header: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 304 | 143 | $self->_assert_mutable; | |||||||||||||||||||||||||||||||||||||||||
| 305 | 143 | _validate_name($name); | |||||||||||||||||||||||||||||||||||||||||
| 306 | 142 | $value = _validate_value($value); | |||||||||||||||||||||||||||||||||||||||||
| 307 | 142 | push @{$self->{headers}}, [ "$name", $value ]; | |||||||||||||||||||||||||||||||||||||||||
| 308 | 142 | return $self; | |||||||||||||||||||||||||||||||||||||||||
| 309 | } | ||||||||||||||||||||||||||||||||||||||||||
| 310 | |||||||||||||||||||||||||||||||||||||||||||
| 311 | 1 | ▶ | sub remove_header ($self, $name) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
remove_header: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 312 | 1 | $self->_assert_mutable; | |||||||||||||||||||||||||||||||||||||||||
| 313 | 1 | _validate_name($name); | |||||||||||||||||||||||||||||||||||||||||
| 314 | 1 | my $wanted = lc $name; | |||||||||||||||||||||||||||||||||||||||||
| 315 | 1 | $self->{headers} = [ grep { lc($_->[0]) ne $wanted } @{$self->{headers}} ]; | |||||||||||||||||||||||||||||||||||||||||
| 316 | 1 | return $self; | |||||||||||||||||||||||||||||||||||||||||
| 317 | } | ||||||||||||||||||||||||||||||||||||||||||
| 318 | |||||||||||||||||||||||||||||||||||||||||||
| 319 | 326 | ▶ | sub _header_values_list ($self, $name) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_header_values_list: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 320 | 326 | _validate_name($name); | |||||||||||||||||||||||||||||||||||||||||
| 321 | 326 | ▶ | return $NATIVE_HEADER_VALUES->($self, $name) if _is_native($self); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 322 | 289 | my $wanted = lc $name; | |||||||||||||||||||||||||||||||||||||||||
| 323 | 118 | return map { $_->[1] } | |||||||||||||||||||||||||||||||||||||||||
| 324 | 483 | grep { lc($_->[0]) eq $wanted } | |||||||||||||||||||||||||||||||||||||||||
| 325 | 289 | @{$self->{headers}}; | |||||||||||||||||||||||||||||||||||||||||
| 326 | } | ||||||||||||||||||||||||||||||||||||||||||
| 327 | |||||||||||||||||||||||||||||||||||||||||||
| 328 | 10 | ▶ | sub header_values ($self, $name) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
header_values: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 329 | 10 | return [ $self->_header_values_list($name) ]; | |||||||||||||||||||||||||||||||||||||||||
| 330 | } | ||||||||||||||||||||||||||||||||||||||||||
| 331 | |||||||||||||||||||||||||||||||||||||||||||
| 332 | 349 | ▶ | sub header_count ($self) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
header_count: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 333 | 349 | ▶ | return $NATIVE_HEADER_COUNT->($self) if _is_native($self); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 334 | 341 | return scalar @{$self->{headers}}; | |||||||||||||||||||||||||||||||||||||||||
| 335 | } | ||||||||||||||||||||||||||||||||||||||||||
| 336 | |||||||||||||||||||||||||||||||||||||||||||
| 337 | 136 | ▶ | sub header_name ($self, $index) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
header_name: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 338 | 136 | $index = _validate_header_index($index); | |||||||||||||||||||||||||||||||||||||||||
| 339 | 134 | ▶ | return undef if $index >= $self->header_count; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 340 | 131 | ▶ | return $NATIVE_HEADER_NAME->($self, $index) if _is_native($self); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 341 | 129 | return $self->{headers}[$index][0]; | |||||||||||||||||||||||||||||||||||||||||
| 342 | } | ||||||||||||||||||||||||||||||||||||||||||
| 343 | |||||||||||||||||||||||||||||||||||||||||||
| 344 | 132 | ▶ | sub header_value ($self, $index) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
header_value: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 345 | 132 | $index = _validate_header_index($index); | |||||||||||||||||||||||||||||||||||||||||
| 346 | 130 | ▶ | return undef if $index >= $self->header_count; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 347 | 128 | ▶ | return $NATIVE_HEADER_VALUE->($self, $index) if _is_native($self); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 348 | 127 | return $self->{headers}[$index][1]; | |||||||||||||||||||||||||||||||||||||||||
| 349 | } | ||||||||||||||||||||||||||||||||||||||||||
| 350 | |||||||||||||||||||||||||||||||||||||||||||
| 351 | 4 | ▶ | sub headers_are_lossless ($self) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
headers_are_lossless: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 352 | 4 | return 1; | |||||||||||||||||||||||||||||||||||||||||
| 353 | } | ||||||||||||||||||||||||||||||||||||||||||
| 354 | |||||||||||||||||||||||||||||||||||||||||||
| 355 | 86 | ▶ | sub _parse_content_length_values (@values) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_parse_content_length_values: called CC=8 SCAR=21.2
| |||||||||||||||||||||||||||||||||||||||||||
| 356 | 86 | ▶ | return undef if !@values; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 357 | 9 | my $length; | |||||||||||||||||||||||||||||||||||||||||
| 358 | 9 | for my $value (@values) { | |||||||||||||||||||||||||||||||||||||||||
| 359 | 10 | for my $member (split /,/, $value, -1) { | |||||||||||||||||||||||||||||||||||||||||
| 360 | 10 | $member =~ s/\A[ \t]+//; | |||||||||||||||||||||||||||||||||||||||||
| 361 | 10 | $member =~ s/[ \t]+\z//; | |||||||||||||||||||||||||||||||||||||||||
| 362 | 10 | ▶ | die 'invalid or conflicting Content-Length' | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$member eq "" or not $member =~ /\A[0-9]+\z/u
MC/DC0%0/2
$member eq "" or not $member =~ /\A[0-9]+\z/u
$member eq ""
not $member =~ /\A[0-9]+\z/u
Truth table33%1/3
A or not(B)
A= $member eq ""B= not $member =~ /\A[0-9]+\z/u
| |||||||||||||||||||||||||||||||||||||||||||
| 363 | if $member eq '' || $member !~ /\A[0-9]+\z/; | ||||||||||||||||||||||||||||||||||||||||||
| 364 | 10 | my $number = 0 + $member; | |||||||||||||||||||||||||||||||||||||||||
| 365 | 10 | ▶ | die 'invalid or conflicting Content-Length' | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $length and $length != $number
MC/DC50%1/2
defined $length and $length != $number
defined $length
$length != $number
Truth table66%2/3
A and B
A= defined $lengthB= $length != $number
| |||||||||||||||||||||||||||||||||||||||||||
| 366 | if defined($length) && $length != $number; | ||||||||||||||||||||||||||||||||||||||||||
| 367 | 9 | $length = $number; | |||||||||||||||||||||||||||||||||||||||||
| 368 | } | ||||||||||||||||||||||||||||||||||||||||||
| 369 | } | ||||||||||||||||||||||||||||||||||||||||||
| 370 | 8 | return $length; | |||||||||||||||||||||||||||||||||||||||||
| 371 | } | ||||||||||||||||||||||||||||||||||||||||||
| 372 | |||||||||||||||||||||||||||||||||||||||||||
| 373 | 113 | ▶ | sub content_length ($self) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
content_length: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 374 | 113 | ▶ | return $NATIVE_CONTENT_LENGTH->($self) if _is_native($self); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 375 | 86 | return _parse_content_length_values($self->_header_values_list('Content-Length')); | |||||||||||||||||||||||||||||||||||||||||
| 376 | } | ||||||||||||||||||||||||||||||||||||||||||
| 377 | |||||||||||||||||||||||||||||||||||||||||||
| 378 | 101 | ▶ | sub body ($self, @args) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
body: called CC=7 SCAR=19.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 379 | 101 | ▶ | if (_is_native($self)) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 380 | 1 | ▶ | die 'received request body is delivered incrementally and is not buffered by Request' | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 381 | if @args; | ||||||||||||||||||||||||||||||||||||||||||
| 382 | 1 | return undef; | |||||||||||||||||||||||||||||||||||||||||
| 383 | } | ||||||||||||||||||||||||||||||||||||||||||
| 384 | 100 | ▶ | return $self->{body} if !@args; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 385 | 13 | ▶ | die 'body accepts exactly one value' if @args != 1; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 386 | 13 | $self->_assert_mutable; | |||||||||||||||||||||||||||||||||||||||||
| 387 | die 'body(): Request already has an incremental body producer' | ||||||||||||||||||||||||||||||||||||||||||
| 388 | 13 | ▶ | if ($self->{body_kind} // '') eq 'stream'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%1/2
$self->{"body_kind"} // ""
MC/DC0%0/1
$self->{"body_kind"} // ""
$self->{"body_kind"}
Truth table50%1/2
A
A= $self->{"body_kind"}
| |||||||||||||||||||||||||||||||||||||||||||
| 389 | 13 | $self->{body_kind} = 'scalar'; | |||||||||||||||||||||||||||||||||||||||||
| 390 | 13 | $self->{body} = _byte_string('body', $args[0]); | |||||||||||||||||||||||||||||||||||||||||
| 391 | 11 | $self->{complete} = 1; | |||||||||||||||||||||||||||||||||||||||||
| 392 | 11 | return $self; | |||||||||||||||||||||||||||||||||||||||||
| 393 | } | ||||||||||||||||||||||||||||||||||||||||||
| 394 | |||||||||||||||||||||||||||||||||||||||||||
| 395 | 30 | ▶ | sub has_buffered_body ($self) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
has_buffered_body: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 396 | 30 | ▶ | return 0 if _is_native($self); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 397 | 28 | ▶ | return ($self->{body_kind} // '') eq 'scalar' ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%2/2
$self->{"body_kind"} // ""
MC/DC100%1/1
$self->{"body_kind"} // ""
$self->{"body_kind"}
Truth table100%2/2
A
A= $self->{"body_kind"}
| |||||||||||||||||||||||||||||||||||||||||||
| 398 | } | ||||||||||||||||||||||||||||||||||||||||||
| 399 | |||||||||||||||||||||||||||||||||||||||||||
| 400 | 28 | ▶ | sub is_complete ($self) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_complete: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 401 | 28 | ▶ | if (_is_native($self)) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 402 | 19 | ▶ | return $NATIVE_COMPLETE{$self} if exists $NATIVE_COMPLETE{$self}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 403 | 16 | ▶ | return $NATIVE_BODY_MODE->($self) eq 'none' ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 404 | } | ||||||||||||||||||||||||||||||||||||||||||
| 405 | 9 | return !!$self->{complete}; | |||||||||||||||||||||||||||||||||||||||||
| 406 | } | ||||||||||||||||||||||||||||||||||||||||||
| 407 | |||||||||||||||||||||||||||||||||||||||||||
| 408 | 7 | ▶ | sub is_mutable ($self) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_mutable: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 409 | 7 | ▶ | return 0 if _is_native($self); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 410 | 5 | ▶ | return $self->{committed} ? 0 : 1; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 411 | } | ||||||||||||||||||||||||||||||||||||||||||
| 412 | |||||||||||||||||||||||||||||||||||||||||||
| 413 | 7 | ▶ | sub _begin_stream_body ($self) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_begin_stream_body: called CC=5 SCAR=17.2
| |||||||||||||||||||||||||||||||||||||||||||
| 414 | 7 | $self->_assert_mutable; | |||||||||||||||||||||||||||||||||||||||||
| 415 | die 'request_body(): Request already has a complete scalar body' | ||||||||||||||||||||||||||||||||||||||||||
| 416 | 7 | ▶ | if ($self->{body_kind} // '') eq 'scalar'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%1/2
$self->{"body_kind"} // ""
MC/DC0%0/1
$self->{"body_kind"} // ""
$self->{"body_kind"}
Truth table50%1/2
A
A= $self->{"body_kind"}
| |||||||||||||||||||||||||||||||||||||||||||
| 417 | die 'request_body(): Request already has an incremental body producer' | ||||||||||||||||||||||||||||||||||||||||||
| 418 | 7 | ▶ | if ($self->{body_kind} // '') eq 'stream'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%1/2
$self->{"body_kind"} // ""
MC/DC0%0/1
$self->{"body_kind"} // ""
$self->{"body_kind"}
Truth table50%1/2
A
A= $self->{"body_kind"}
| |||||||||||||||||||||||||||||||||||||||||||
| 419 | 7 | $self->{body_kind} = 'stream'; | |||||||||||||||||||||||||||||||||||||||||
| 420 | 7 | $self->{complete} = 0; | |||||||||||||||||||||||||||||||||||||||||
| 421 | 7 | return $self; | |||||||||||||||||||||||||||||||||||||||||
| 422 | } | ||||||||||||||||||||||||||||||||||||||||||
| 423 | |||||||||||||||||||||||||||||||||||||||||||
| 424 | 19 | ▶ | sub _has_scalar_body ($self) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_has_scalar_body: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 425 | 19 | return $self->has_buffered_body; | |||||||||||||||||||||||||||||||||||||||||
| 426 | } | ||||||||||||||||||||||||||||||||||||||||||
| 427 | |||||||||||||||||||||||||||||||||||||||||||
| 428 | 24 | ▶ | sub _has_incremental_body ($self) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_has_incremental_body: called CC=3 SCAR=11.1
| |||||||||||||||||||||||||||||||||||||||||||
| 429 | 24 | ▶ | return 0 if _is_native($self); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 430 | 24 | ▶ | return ($self->{body_kind} // '') eq 'stream'; | ||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$self->{"body_kind"} // ""
MC/DC100%1/1
$self->{"body_kind"} // ""
$self->{"body_kind"}
Truth table100%2/2
A
A= $self->{"body_kind"}
| |||||||||||||||||||||||||||||||||||||||||||
| 431 | } | ||||||||||||||||||||||||||||||||||||||||||
| 432 | |||||||||||||||||||||||||||||||||||||||||||
| 433 | 29 | ▶ | sub _mark_complete ($self) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_mark_complete: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 434 | 29 | ▶ | if (_is_native($self)) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 435 | 23 | $NATIVE_COMPLETE{$self} = 1; | |||||||||||||||||||||||||||||||||||||||||
| 436 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 437 | 6 | $self->{complete} = 1; | |||||||||||||||||||||||||||||||||||||||||
| 438 | } | ||||||||||||||||||||||||||||||||||||||||||
| 439 | 29 | return $self; | |||||||||||||||||||||||||||||||||||||||||
| 440 | } | ||||||||||||||||||||||||||||||||||||||||||
| 441 | |||||||||||||||||||||||||||||||||||||||||||
| 442 | 2 | ▶ | sub _mark_incomplete ($self) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_mark_incomplete: called CC=2 SCAR=7.1
| |||||||||||||||||||||||||||||||||||||||||||
| 443 | 2 | ▶ | die 'cannot mark a received Request incomplete' if _is_native($self); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 444 | 2 | $self->{complete} = 0; | |||||||||||||||||||||||||||||||||||||||||
| 445 | 2 | return $self; | |||||||||||||||||||||||||||||||||||||||||
| 446 | } | ||||||||||||||||||||||||||||||||||||||||||
| 447 | |||||||||||||||||||||||||||||||||||||||||||
| 448 | 79 | ▶ | sub _mark_committed ($self) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_mark_committed: called CC=2 SCAR=7.1
| |||||||||||||||||||||||||||||||||||||||||||
| 449 | 79 | ▶ | die 'cannot commit a received Request' if _is_native($self); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 450 | 79 | $self->{committed} = 1; | |||||||||||||||||||||||||||||||||||||||||
| 451 | 79 | return $self; | |||||||||||||||||||||||||||||||||||||||||
| 452 | } | ||||||||||||||||||||||||||||||||||||||||||
| 453 | |||||||||||||||||||||||||||||||||||||||||||
| 454 | 163 | ▶ | sub _http1_body_mode ($self) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_http1_body_mode: called CC=2 SCAR=7.2
| |||||||||||||||||||||||||||||||||||||||||||
| 455 | 163 | ▶ | die '_http1_body_mode is only available for a parsed HTTP/1 request' | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 456 | if !_is_native($self); | ||||||||||||||||||||||||||||||||||||||||||
| 457 | 163 | return $NATIVE_BODY_MODE->($self); | |||||||||||||||||||||||||||||||||||||||||
| 458 | } | ||||||||||||||||||||||||||||||||||||||||||
| 459 | |||||||||||||||||||||||||||||||||||||||||||
| 460 | 30 | ▶ | sub _http1_keep_alive ($self) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_http1_keep_alive: called CC=2 SCAR=7.2
| |||||||||||||||||||||||||||||||||||||||||||
| 461 | 30 | ▶ | die '_http1_keep_alive is only available for a parsed HTTP/1 request' | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 462 | if !_is_native($self); | ||||||||||||||||||||||||||||||||||||||||||
| 463 | 30 | return $NATIVE_KEEP_ALIVE->($self); | |||||||||||||||||||||||||||||||||||||||||
| 464 | } | ||||||||||||||||||||||||||||||||||||||||||
| 465 | |||||||||||||||||||||||||||||||||||||||||||
| 466 | 248 | ▶ | sub DESTROY ($self) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
DESTROY: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 467 | 248 | ▶ | return if !_is_native($self); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 468 | 138 | $NATIVE_DESTROY->($self); | |||||||||||||||||||||||||||||||||||||||||
| 469 | 138 | return; | |||||||||||||||||||||||||||||||||||||||||
| 470 | } | ||||||||||||||||||||||||||||||||||||||||||
| 471 | |||||||||||||||||||||||||||||||||||||||||||
| 472 | 42 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 473 | |||||||||||||||||||||||||||||||||||||||||||
| 474 | __END__ | ||||||||||||||||||||||||||||||||||||||||||