| 1 | package Uniform::HTTP::FastPath; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 2 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 2 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 2 | ▶ | use Carp qw(croak); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | 2 | ▶ | use Uniform::HTTP::Message (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 2 | ▶ | use Uniform::HTTP::Request (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 2 | ▶ | use Uniform::HTTP::Response (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 2 | our $VERSION = '0.05'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 2 | ▶ | use constant ABI_VERSION => 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | 2 | ▶ | use constant KIND_MESSAGE => 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 2 | ▶ | use constant KIND_REQUEST => 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | 2 | ▶ | use constant KIND_RESPONSE => 2; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 2 | ▶ | use constant FLAG_HAS_BUFFERED_BODY => 0x001; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | 2 | ▶ | use constant FLAG_COMPLETE => 0x002; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | 2 | ▶ | use constant FLAG_MUTABLE => 0x004; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | 2 | ▶ | use constant FLAG_INITIAL_MUTABLE => 0x008; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | 2 | ▶ | use constant FLAG_BODY_MUTABLE => 0x010; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | 2 | ▶ | use constant FLAG_TRAILERS_MUTABLE => 0x020; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | 2 | ▶ | use constant FLAG_HEADERS_LOSSLESS => 0x040; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | 2 | ▶ | use constant FLAG_TRAILERS_LOSSLESS => 0x080; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | 2 | ▶ | use constant FLAG_TARGET_EXACT => 0x100; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | 2 | ▶ | use constant SLOT_ABI => 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | 2 | ▶ | use constant SLOT_KIND => 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | 2 | ▶ | use constant SLOT_FLAGS => 2; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | 2 | ▶ | use constant SLOT_VERSION => 3; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | 2 | ▶ | use constant SLOT_METHOD => 4; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | 2 | ▶ | use constant SLOT_TARGET => 5; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | 2 | ▶ | use constant SLOT_SCHEME => 6; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | 2 | ▶ | use constant SLOT_AUTHORITY => 7; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | 2 | ▶ | use constant SLOT_PROTOCOL => 8; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | 2 | ▶ | use constant SLOT_STATUS => 9; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | 2 | ▶ | use constant SLOT_REASON => 10; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | 2 | ▶ | use constant SLOT_HEADERS => 11; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | 2 | ▶ | use constant SLOT_TRAILERS => 12; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | 2 | ▶ | use constant SLOT_BODY => 13; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | 2 | ▶ | use constant SLOT_COUNT => 14; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | 2 | ▶ | use constant _ALL_FLAGS => 0x1ff; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | 8 | ▶ | sub can_view { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
can_view: called CC=6 SCAR=18.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | 8 | ▶ | croak 'can_view() requires exactly one message' unless @_ == 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | 8 | my ($message) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | 8 | ▶ | my $class = ref($message) || ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
ref $message || ''
MC/DC0%0/1
ref $message || ''
ref $message
Truth table50%1/2
A
A= ref $message
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | 8 | ▶ | return 1 if $class eq 'Uniform::HTTP::Message'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | 6 | ▶ | return 1 if $class eq 'Uniform::HTTP::Request'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | 3 | ▶ | return 1 if $class eq 'Uniform::HTTP::Response'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | 2 | return 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | 6 | ▶ | sub view { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
view: called CC=27 SCAR=33.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | 6 | ▶ | croak 'view() requires a message and optional ABI version' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
@_ == 1 or @_ == 2
MC/DC0%0/2
@_ == 1 or @_ == 2
@_ == 1
@_ == 2
Truth table66%2/3
A or B
A= @_ == 1B= @_ == 2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | unless @_ == 1 || @_ == 2; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | 6 | my ($message, $abi) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | 6 | ▶ | $abi = ABI_VERSION unless defined $abi; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | 6 | ▶ | croak 'unsupported Uniform::HTTP fast-path ABI' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%3/6
not ref $abi and $abi =~ /\A[0-9]+\z/ and $abi == 1
not ref $abi and $abi =~ /\A[0-9]+\z/
MC/DC33%1/3
not ref $abi and $abi =~ /\A[0-9]+\z/ and $abi == 1
not ref $abi
$abi =~ /\A[0-9]+\z/
$abi == 1
Truth table50%2/4
not(A) and B and C
A= not ref $abiB= $abi =~ /\A[0-9]+\z/C= $abi == 1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | unless !ref($abi) && $abi =~ /\A[0-9]+\z/ && $abi == ABI_VERSION; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | 5 | ▶ | croak 'fast path requires an exact canonical Uniform::HTTP message class' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | unless can_view($message); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | 4 | my $class = ref $message; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | 4 | ▶ | my $kind = $class eq 'Uniform::HTTP::Request' ? KIND_REQUEST | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | : $class eq 'Uniform::HTTP::Response' ? KIND_RESPONSE | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | : KIND_MESSAGE; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | 4 | my $flags = FLAG_HEADERS_LOSSLESS | FLAG_TRAILERS_LOSSLESS; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | 4 | ▶ | $flags |= FLAG_HAS_BUFFERED_BODY if $message->{has_buffered_body}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | 4 | ▶ | $flags |= FLAG_COMPLETE if $message->{complete}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | 4 | ▶ | $flags |= FLAG_MUTABLE if $message->{mutable}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | $flags |= FLAG_INITIAL_MUTABLE | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | 4 | ▶ | if $message->{mutable} && !$message->{initial_frozen}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$message->{"mutable"} and not $message->{"initial_frozen"}
MC/DC100%2/2
$message->{"mutable"} and not $message->{"initial_frozen"}
$message->{"mutable"}
not $message->{"initial_frozen"}
Truth table100%3/3
A and not(B)
A= $message->{"mutable"}B= not $message->{"initial_frozen"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | 4 | ▶ | $flags |= FLAG_BODY_MUTABLE if $message->{mutable}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | $flags |= FLAG_TRAILERS_MUTABLE | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | 4 | ▶ | if $message->{mutable} && !$message->{trailers_frozen}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$message->{"mutable"} and not $message->{"trailers_frozen"}
MC/DC50%1/2
$message->{"mutable"} and not $message->{"trailers_frozen"}
$message->{"mutable"}
not $message->{"trailers_frozen"}
Truth table66%2/3
A and not(B)
A= $message->{"mutable"}B= not $message->{"trailers_frozen"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | 4 | ▶ | $flags |= FLAG_TARGET_EXACT if $kind == KIND_REQUEST; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | return [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | ABI_VERSION, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | $kind, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | $flags, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | $message->{version}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | $kind == KIND_REQUEST ? $message->{method} : undef, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | $kind == KIND_REQUEST ? $message->{target} : undef, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | $kind == KIND_REQUEST ? $message->{scheme} : undef, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | $kind == KIND_REQUEST ? $message->{authority} : undef, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | $kind == KIND_REQUEST ? $message->{protocol} : undef, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | $kind == KIND_RESPONSE ? $message->{status} : undef, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | $kind == KIND_RESPONSE ? $message->{reason} : undef, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | $message->{headers}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | $message->{trailers}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | $message->{has_buffered_body} ? $message->{body} : undef, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | 4 | ▶ | ]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 8 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | 5 | ▶ | sub request_from_validated { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
request_from_validated: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | 5 | ▶ | croak 'request_from_validated() requires exactly one fast-path view' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | unless @_ == 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | 5 | my ($view) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | 5 | _validate_view($view, KIND_REQUEST); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | 1 | my $self = _common_from_view($view); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | 1 | $self->{method} = $view->[SLOT_METHOD]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | 1 | $self->{target} = $view->[SLOT_TARGET]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | 1 | $self->{scheme} = $view->[SLOT_SCHEME]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | 1 | $self->{authority} = $view->[SLOT_AUTHORITY]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | 1 | $self->{protocol} = $view->[SLOT_PROTOCOL]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | 1 | return bless $self, 'Uniform::HTTP::Request'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | 1 | ▶ | sub response_from_validated { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
response_from_validated: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | 1 | ▶ | croak 'response_from_validated() requires exactly one fast-path view' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | unless @_ == 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | 1 | my ($view) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | 1 | _validate_view($view, KIND_RESPONSE); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | 1 | my $self = _common_from_view($view); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | 1 | $self->{status} = $view->[SLOT_STATUS]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | 1 | $self->{reason} = $view->[SLOT_REASON]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | 1 | return bless $self, 'Uniform::HTTP::Response'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | 2 | ▶ | sub _common_from_view { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_common_from_view: called CC=7 SCAR=19.5
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | 2 | my ($view) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | 2 | my $flags = $view->[SLOT_FLAGS]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | return { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | 2 | ▶ | version => $view->[SLOT_VERSION], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 6 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | headers => $view->[SLOT_HEADERS], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | trailers => $view->[SLOT_TRAILERS], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | initial_frozen => $flags & FLAG_INITIAL_MUTABLE ? 0 : 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | trailers_frozen => $flags & FLAG_TRAILERS_MUTABLE ? 0 : 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | body => $flags & FLAG_HAS_BUFFERED_BODY | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | ? $view->[SLOT_BODY] : undef, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | has_buffered_body => $flags & FLAG_HAS_BUFFERED_BODY ? 1 : 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | complete => $flags & FLAG_COMPLETE ? 1 : 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | mutable => $flags & FLAG_MUTABLE ? 1 : 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | 6 | ▶ | sub _validate_view { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_validate_view: called CC=37 SCAR=44.7
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | 6 | my ($view, $kind) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | 6 | ▶ | croak 'fast-path view must be an array reference' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | unless ref($view) eq 'ARRAY'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | 6 | ▶ | croak 'fast-path view has the wrong number of slots' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | unless @$view == SLOT_COUNT; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | 6 | ▶ | croak 'unsupported Uniform::HTTP fast-path ABI' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition44%4/9
defined $view->[0] and not ref $view->[0] and $view->[0] =~ /\A[0-9]+\z/ and $view->[0] == 1
defined $view->[0] and not ref $view->[0] and $view->[0] =~ /\A[0-9]+\z/
defined $view->[0] and not ref $view->[0]
MC/DC25%1/4
defined $view->[0] and not ref $view->[0] and $view->[0] =~ /\A[0-9]+\z/ and $view->[0] == 1
defined $view->[0]
not ref $view->[0]
$view->[0] =~ /\A[0-9]+\z/
$view->[0] == 1
Truth table40%2/5
A and not(B) and C and D
A= defined $view->[0]B= not ref $view->[0]C= $view->[0] =~ /\A[0-9]+\z/D= $view->[0] == 1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | unless defined($view->[SLOT_ABI]) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | && !ref($view->[SLOT_ABI]) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | && $view->[SLOT_ABI] =~ /\A[0-9]+\z/ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | && $view->[SLOT_ABI] == ABI_VERSION; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | 5 | ▶ | croak 'fast-path view has the wrong message kind' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition44%4/9
defined $view->[1] and not ref $view->[1] and $view->[1] =~ /\A[0-9]+\z/ and $view->[1] == $kind
defined $view->[1] and not ref $view->[1] and $view->[1] =~ /\A[0-9]+\z/
defined $view->[1] and not ref $view->[1]
MC/DC25%1/4
defined $view->[1] and not ref $view->[1] and $view->[1] =~ /\A[0-9]+\z/ and $view->[1] == $kind
defined $view->[1]
not ref $view->[1]
$view->[1] =~ /\A[0-9]+\z/
$view->[1] == $kind
Truth table40%2/5
A and not(B) and C and D
A= defined $view->[1]B= not ref $view->[1]C= $view->[1] =~ /\A[0-9]+\z/D= $view->[1] == $kind
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | unless defined($view->[SLOT_KIND]) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | && !ref($view->[SLOT_KIND]) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | && $view->[SLOT_KIND] =~ /\A[0-9]+\z/ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | && $view->[SLOT_KIND] == $kind; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | 4 | my $flags = $view->[SLOT_FLAGS]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | 4 | ▶ | croak 'fast-path flags must be a non-negative integer' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
defined $flags and not ref $flags and $flags =~ /\A[0-9]+\z/
defined $flags and not ref $flags
MC/DC0%0/3
defined $flags and not ref $flags and $flags =~ /\A[0-9]+\z/
defined $flags
not ref $flags
$flags =~ /\A[0-9]+\z/
Truth table25%1/4
A and not(B) and C
A= defined $flagsB= not ref $flagsC= $flags =~ /\A[0-9]+\z/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | unless defined($flags) && !ref($flags) && $flags =~ /\A[0-9]+\z/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | 4 | ▶ | croak 'fast-path view contains unknown flags' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | if $flags & ~_ALL_FLAGS; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | 4 | ▶ | croak 'fast-path headers must be an array reference' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | unless ref($view->[SLOT_HEADERS]) eq 'ARRAY'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | 3 | ▶ | croak 'fast-path trailers must be an array reference' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | unless ref($view->[SLOT_TRAILERS]) eq 'ARRAY'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | 3 | ▶ | croak 'trusted canonical construction requires lossless headers' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | unless $flags & FLAG_HEADERS_LOSSLESS; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | 3 | ▶ | croak 'trusted canonical construction requires lossless trailers' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | unless $flags & FLAG_TRAILERS_LOSSLESS; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | 3 | ▶ | if ($flags & FLAG_HAS_BUFFERED_BODY) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | 2 | ▶ | croak 'buffered fast-path body must be a defined plain scalar' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $view->[13] and not ref $view->[13]
MC/DC0%0/2
defined $view->[13] and not ref $view->[13]
defined $view->[13]
not ref $view->[13]
Truth table33%1/3
A and not(B)
A= defined $view->[13]B= not ref $view->[13]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | unless defined($view->[SLOT_BODY]) && !ref($view->[SLOT_BODY]); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | 1 | ▶ | croak 'fast-path body slot must be undef when no buffered body is present' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | if defined $view->[SLOT_BODY]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | 3 | ▶ | my $mutable = $flags & FLAG_MUTABLE ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | 3 | ▶ | my $body_mutable = $flags & FLAG_BODY_MUTABLE ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | 3 | ▶ | croak 'fast-path body mutability is not canonical' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | unless $mutable == $body_mutable; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | 3 | ▶ | if (!$mutable) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | 1 | ▶ | croak 'immutable fast-path view advertises a mutable section' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | if $flags & (FLAG_INITIAL_MUTABLE | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | | FLAG_BODY_MUTABLE | FLAG_TRAILERS_MUTABLE); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | 3 | ▶ | if ($kind == KIND_REQUEST) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | 2 | ▶ | croak 'trusted request requires exact target fidelity' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | unless $flags & FLAG_TARGET_EXACT; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | 1 | ▶ | croak 'trusted request method must be a defined plain scalar' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $view->[4] and not ref $view->[4]
MC/DC0%0/2
defined $view->[4] and not ref $view->[4]
defined $view->[4]
not ref $view->[4]
Truth table33%1/3
A and not(B)
A= defined $view->[4]B= not ref $view->[4]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | unless defined($view->[SLOT_METHOD]) && !ref($view->[SLOT_METHOD]); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | 1 | ▶ | croak 'trusted request target must be a defined plain scalar' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $view->[5] and not ref $view->[5]
MC/DC0%0/2
defined $view->[5] and not ref $view->[5]
defined $view->[5]
not ref $view->[5]
Truth table33%1/3
A and not(B)
A= defined $view->[5]B= not ref $view->[5]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | unless defined($view->[SLOT_TARGET]) && !ref($view->[SLOT_TARGET]); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | 1 | ▶ | croak 'response fast-path view must not set request target fidelity' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | if $flags & FLAG_TARGET_EXACT; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | 1 | ▶ | croak 'trusted response status must be a defined plain scalar' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $view->[9] and not ref $view->[9]
MC/DC0%0/2
defined $view->[9] and not ref $view->[9]
defined $view->[9]
not ref $view->[9]
Truth table33%1/3
A and not(B)
A= defined $view->[9]B= not ref $view->[9]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | unless defined($view->[SLOT_STATUS]) && !ref($view->[SLOT_STATUS]); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | 2 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | 2 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||