| 1 | package Linux::Event::HTTP::_Upgrade; | ||||||||||||||||||||||||||||||||||||||||||||||
| 2 | 1 | ▶ | use v5.36; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 1 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||||||||||||||||||||
| 6 | 1 | ▶ | use Carp qw(croak); | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 7 | 1 | ▶ | use Scalar::Util qw(refaddr); | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 1 | ▶ | use Linux::Event::IO::Sock::Stream (); | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 1 | our $VERSION = '0.003'; | |||||||||||||||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 2 | ▶ | sub _load_target ($target) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_load_target: called CC=6 SCAR=23.5
| |||||||||||||||||||||||||||||||||||||||||||||||
| 14 | 2 | ▶ | croak 'upgrade(): target class must be a package name' | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
not defined $target or ref $target or not $target =~ /\A[A-Za-z_][A-Za-z0-9_]*(?:::[A-Za-z_][A-Za-z0-9_]*)*\z/u
not defined $target or ref $target
MC/DC0%0/3
not defined $target or ref $target or not $target =~ /\A[A-Za-z_][A-Za-z0-9_]*(?:::[A-Za-z_][A-Za-z0-9_]*)*\z/u
not defined $target
ref $target
not $target =~ /\A[A-Za-z_][A-Za-z0-9_]*(?:::[A-Za-z_][A-Za-z0-9_]*)*\z/u
Truth table25%1/4
not(A) or B or not(C)
A= not defined $targetB= ref $targetC= not $target =~ /\A[A-Za-z_][A-Za-z0-9_]*(?:::[A-Za-z_][A-Za-z0-9_]*)*\z/u
| |||||||||||||||||||||||||||||||||||||||||||||||
| 15 | if !defined($target) || ref($target) | ||||||||||||||||||||||||||||||||||||||||||||||
| 16 | || $target !~ /\A[A-Za-z_][A-Za-z0-9_]*(?:::[A-Za-z_][A-Za-z0-9_]*)*\z/; | ||||||||||||||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||||||||||||||
| 18 | 2 | ▶ | if (!$target->can('transition_to')) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 0 | (my $file = "$target.pm") =~ s{::}{/}g; | |||||||||||||||||||||||||||||||||||||||||||||
| 20 | 0 | require $file; | |||||||||||||||||||||||||||||||||||||||||||||
| 21 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||||||||||||||||||||
| 23 | 2 | ▶ | croak 'upgrade(): target class must inherit Linux::Event::IO::Sock::Stream' | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 24 | if !$target->isa('Linux::Event::IO::Sock::Stream'); | ||||||||||||||||||||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||||||||||||||||||||
| 26 | 2 | return $target; | |||||||||||||||||||||||||||||||||||||||||||||
| 27 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||||||||||||||||||||
| 29 | 6 | ▶ | sub _tokens ($where, @values) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_tokens: called CC=5 SCAR=16.7
| |||||||||||||||||||||||||||||||||||||||||||||||
| 30 | 6 | my @token; | |||||||||||||||||||||||||||||||||||||||||||||
| 31 | 6 | for my $value (@values) { | |||||||||||||||||||||||||||||||||||||||||||||
| 32 | 6 | for my $member (split /,/, $value, -1) { | |||||||||||||||||||||||||||||||||||||||||||||
| 33 | 6 | $member =~ s/\A[ \t]+//; | |||||||||||||||||||||||||||||||||||||||||||||
| 34 | 6 | $member =~ s/[ \t]+\z//; | |||||||||||||||||||||||||||||||||||||||||||||
| 35 | 6 | ▶ | croak "upgrade(): invalid $where field value" | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$member eq "" or not $member =~ m[\A[!#\$%&'*+\-.^_`|~0-9A-Za-z]+(?:/[!#\$%&'*+\-.^_`|~0-9A-Za-z]+)?\z]u
MC/DC0%0/2
$member eq "" or not $member =~ m[\A[!#\$%&'*+\-.^_`|~0-9A-Za-z]+(?:/[!#\$%&'*+\-.^_`|~0-9A-Za-z]+)?\z]u
$member eq ""
not $member =~ m[\A[!#\$%&'*+\-.^_`|~0-9A-Za-z]+(?:/[!#\$%&'*+\-.^_`|~0-9A-Za-z]+)?\z]u
Truth table33%1/3
A or not(B)
A= $member eq ""B= not $member =~ m[\A[!#\$%&'*+\-.^_`|~0-9A-Za-z]+(?:/[!#\$%&'*+\-.^_`|~0-9A-Za-z]+)?\z]u
| |||||||||||||||||||||||||||||||||||||||||||||||
| 36 | if $member eq '' | ||||||||||||||||||||||||||||||||||||||||||||||
| 37 | || $member !~ /\A[!#\$%&'*+\-.^_`|~0-9A-Za-z]+(?:\/[!#\$%&'*+\-.^_`|~0-9A-Za-z]+)?\z/; | ||||||||||||||||||||||||||||||||||||||||||||||
| 38 | 6 | push @token, lc $member; | |||||||||||||||||||||||||||||||||||||||||||||
| 39 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 40 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 41 | 6 | return @token; | |||||||||||||||||||||||||||||||||||||||||||||
| 42 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||||||||||||||||||||
| 44 | 6 | ▶ | sub _connection_has ($values, $wanted) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_connection_has: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||||||||||||||||||||
| 45 | 6 | for my $value (@$values) { | |||||||||||||||||||||||||||||||||||||||||||||
| 46 | 6 | for my $member (split /,/, $value, -1) { | |||||||||||||||||||||||||||||||||||||||||||||
| 47 | 10 | $member =~ s/\A[ \t]+//; | |||||||||||||||||||||||||||||||||||||||||||||
| 48 | 10 | $member =~ s/[ \t]+\z//; | |||||||||||||||||||||||||||||||||||||||||||||
| 49 | 10 | ▶ | return 1 if lc($member) eq $wanted; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 50 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 51 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 52 | 3 | return 0; | |||||||||||||||||||||||||||||||||||||||||||||
| 53 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||||||||||||||||||||
| 55 | 4 | ▶ | sub schedule ($class, $conn, $transaction, $target) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
schedule: called CC=36 SCAR=44.6
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 56 | croak 'upgrade(): connection is closing or closed' | ||||||||||||||||||||||||||||||||||||||||||||||
| 57 | 4 | ▶ | if $conn->{_http_closing} || $conn->is_closed; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$conn->{"_http_closing"} or $conn->is_closed
MC/DC0%0/2
$conn->{"_http_closing"} or $conn->is_closed
$conn->{"_http_closing"}
$conn->is_closed
Truth table33%1/3
A or B
A= $conn->{"_http_closing"}B= $conn->is_closed
| |||||||||||||||||||||||||||||||||||||||||||||||
| 58 | 4 | ▶ | croak 'upgrade(): Transaction is already terminal' | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 59 | if $transaction->is_terminal; | ||||||||||||||||||||||||||||||||||||||||||||||
| 60 | 4 | ▶ | croak 'upgrade(): response output has already started' | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 61 | if $transaction->is_response_started; | ||||||||||||||||||||||||||||||||||||||||||||||
| 62 | 4 | ▶ | croak 'upgrade(): Transaction already has an Upgrade handoff pending' | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 63 | if $transaction->is_upgrading; | ||||||||||||||||||||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||||||||||||||||||||
| 65 | 4 | my $active = $conn->{_http_active_transaction}; | |||||||||||||||||||||||||||||||||||||||||||||
| 66 | 4 | ▶ | croak 'upgrade(): Transaction is not active on this HTTP connection' | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
not $active or builtin::refaddr($active) != builtin::refaddr($transaction)
MC/DC0%0/2
not $active or builtin::refaddr($active) != builtin::refaddr($transaction)
not $active
builtin::refaddr($active) != builtin::refaddr($transaction)
Truth table33%1/3
not(A) or B
A= not $activeB= builtin::refaddr($active) != builtin::refaddr($transaction)
| |||||||||||||||||||||||||||||||||||||||||||||||
| 67 | if !$active || refaddr($active) != refaddr($transaction); | ||||||||||||||||||||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||||||||||||||||||||
| 69 | 4 | ▶ | my $req = $transaction->request | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 70 | or croak 'upgrade(): active Request is missing'; | ||||||||||||||||||||||||||||||||||||||||||||||
| 71 | 4 | ▶ | my $response = $transaction->response | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 72 | or croak 'upgrade(): active Response is missing'; | ||||||||||||||||||||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||||||||||||||||||||
| 74 | 4 | ▶ | croak 'upgrade(): response message has already been committed' | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 75 | if $response->_is_committed; | ||||||||||||||||||||||||||||||||||||||||||||||
| 76 | 4 | ▶ | croak 'upgrade(): response is already complete' | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 77 | if $response->is_complete; | ||||||||||||||||||||||||||||||||||||||||||||||
| 78 | 4 | ▶ | croak 'upgrade(): response already has an incremental body producer' | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 79 | if $response->_has_incremental_body; | ||||||||||||||||||||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||||||||||||||||||||
| 81 | my $request_state = $conn->{_http_request_state} | ||||||||||||||||||||||||||||||||||||||||||||||
| 82 | 4 | ▶ | or croak 'upgrade(): request state is missing'; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||||||||||||||||||||
| 84 | 4 | ▶ | croak 'upgrade(): HTTP Upgrade requires HTTP/1.1' | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 85 | if $req->version ne '1.1'; | ||||||||||||||||||||||||||||||||||||||||||||||
| 86 | 4 | ▶ | croak 'upgrade(): request body must be empty before protocol handoff' | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition62%5/8
$req->_http1_body_mode eq "chunked" or $req->_http1_body_mode eq "content-length" and ($req->content_length // 0) ne 0
$req->_http1_body_mode eq "content-length" and ($req->content_length // 0) ne 0
$req->content_length // 0
MC/DC33%1/3
$req->_http1_body_mode eq "chunked" or $req->_http1_body_mode eq "content-length" and ($req->content_length // 0) ne 0
$req->_http1_body_mode eq "chunked"
$req->_http1_body_mode eq "content-length"
$req->content_length
Truth table50%2/4
A or B and C
A= $req->_http1_body_mode eq "chunked"B= $req->_http1_body_mode eq "content-length"C= $req->content_length
| |||||||||||||||||||||||||||||||||||||||||||||||
| 87 | if $req->_http1_body_mode eq 'chunked' | ||||||||||||||||||||||||||||||||||||||||||||||
| 88 | || ($req->_http1_body_mode eq 'content-length' | ||||||||||||||||||||||||||||||||||||||||||||||
| 89 | && ($req->content_length // '0') ne '0'); | ||||||||||||||||||||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||||||||||||||||||||
| 91 | 3 | my @request_connection = $req->_header_values_list('Connection'); | |||||||||||||||||||||||||||||||||||||||||||||
| 92 | 3 | ▶ | croak 'upgrade(): request Connection field must contain Upgrade' | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 93 | if !_connection_has(\@request_connection, 'upgrade'); | ||||||||||||||||||||||||||||||||||||||||||||||
| 94 | 3 | ▶ | croak 'upgrade(): request cannot combine Connection: close with Upgrade' | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
_connection_has(\@request_connection, "close") or not $req->_http1_keep_alive
MC/DC0%0/2
_connection_has(\@request_connection, "close") or not $req->_http1_keep_alive
_connection_has(\@request_connection, "close")
not $req->_http1_keep_alive
Truth table33%1/3
A or not(B)
A= _connection_has(\@request_connection, "close")B= not $req->_http1_keep_alive
| |||||||||||||||||||||||||||||||||||||||||||||||
| 95 | if _connection_has(\@request_connection, 'close') | ||||||||||||||||||||||||||||||||||||||||||||||
| 96 | || !$req->_http1_keep_alive; | ||||||||||||||||||||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||||||||||||||||||||
| 98 | 3 | my @offered = _tokens('request Upgrade', $req->_header_values_list('Upgrade')); | |||||||||||||||||||||||||||||||||||||||||||||
| 99 | 3 | ▶ | croak 'upgrade(): request must contain an Upgrade field' if !@offered; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||||||||||||||||||||
| 101 | 3 | my @selected = _tokens( | |||||||||||||||||||||||||||||||||||||||||||||
| 102 | 'response Upgrade', $response->_header_values_list('Upgrade'), | ||||||||||||||||||||||||||||||||||||||||||||||
| 103 | ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 104 | 3 | ▶ | croak 'upgrade(): response must select at least one Upgrade protocol' | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 105 | if !@selected; | ||||||||||||||||||||||||||||||||||||||||||||||
| 106 | 3 | my %offered = map { $_ => 1 } @offered; | |||||||||||||||||||||||||||||||||||||||||||||
| 107 | 3 | for my $protocol (@selected) { | |||||||||||||||||||||||||||||||||||||||||||||
| 108 | croak "upgrade(): response selected protocol not offered by request: $protocol" | ||||||||||||||||||||||||||||||||||||||||||||||
| 109 | 3 | ▶ | if !$offered{$protocol}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 110 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||||||||||||||||||||
| 112 | 2 | ▶ | croak 'upgrade(): response cannot contain Content-Length' | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 113 | if $response->_header_values_list('Content-Length'); | ||||||||||||||||||||||||||||||||||||||||||||||
| 114 | 2 | ▶ | croak 'upgrade(): response cannot contain Transfer-Encoding' | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 115 | if $response->_header_values_list('Transfer-Encoding'); | ||||||||||||||||||||||||||||||||||||||||||||||
| 116 | |||||||||||||||||||||||||||||||||||||||||||||||
| 117 | 2 | my @response_connection = $response->_header_values_list('Connection'); | |||||||||||||||||||||||||||||||||||||||||||||
| 118 | 2 | ▶ | if (@response_connection) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 119 | 0 | ▶ | croak 'upgrade(): response Connection field must contain Upgrade' | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 120 | if !_connection_has(\@response_connection, 'upgrade'); | ||||||||||||||||||||||||||||||||||||||||||||||
| 121 | 0 | ▶ | croak 'upgrade(): response cannot combine Connection: close with Upgrade' | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 122 | if _connection_has(\@response_connection, 'close'); | ||||||||||||||||||||||||||||||||||||||||||||||
| 123 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 124 | |||||||||||||||||||||||||||||||||||||||||||||||
| 125 | 2 | ▶ | croak 'upgrade(): cannot replace an explicit non-upgrade status' | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$response->status != 200 and $response->status != 101
MC/DC0%0/2
$response->status != 200 and $response->status != 101
$response->status != 200
$response->status != 101
Truth table33%1/3
A and B
A= $response->status != 200B= $response->status != 101
| |||||||||||||||||||||||||||||||||||||||||||||||
| 126 | if $response->status != 200 && $response->status != 101; | ||||||||||||||||||||||||||||||||||||||||||||||
| 127 | |||||||||||||||||||||||||||||||||||||||||||||||
| 128 | 2 | $target = _load_target($target); | |||||||||||||||||||||||||||||||||||||||||||||
| 129 | 2 | ▶ | croak "upgrade(): $target is already the active Connection class" | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 130 | if ref($conn) eq $target; | ||||||||||||||||||||||||||||||||||||||||||||||
| 131 | |||||||||||||||||||||||||||||||||||||||||||||||
| 132 | 2 | ▶ | $response->header('Connection', 'Upgrade') if !@response_connection; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 133 | 2 | $response->status(101); | |||||||||||||||||||||||||||||||||||||||||||||
| 134 | 2 | $response->reason(undef); | |||||||||||||||||||||||||||||||||||||||||||||
| 135 | 2 | $response->_commit; | |||||||||||||||||||||||||||||||||||||||||||||
| 136 | |||||||||||||||||||||||||||||||||||||||||||||||
| 137 | 2 | $transaction->_set_upgrade_pending; | |||||||||||||||||||||||||||||||||||||||||||||
| 138 | $conn->{_http_pending_upgrade} = { | ||||||||||||||||||||||||||||||||||||||||||||||
| 139 | 2 | ▶ | transaction => $transaction, | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 140 | target => $target, | ||||||||||||||||||||||||||||||||||||||||||||||
| 141 | resume_read => $conn->is_read_paused ? 0 : 1, | ||||||||||||||||||||||||||||||||||||||||||||||
| 142 | }; | ||||||||||||||||||||||||||||||||||||||||||||||
| 143 | |||||||||||||||||||||||||||||||||||||||||||||||
| 144 | 2 | my $state = { | |||||||||||||||||||||||||||||||||||||||||||||
| 145 | connection => $conn, | ||||||||||||||||||||||||||||||||||||||||||||||
| 146 | transaction => $transaction, | ||||||||||||||||||||||||||||||||||||||||||||||
| 147 | target => $target, | ||||||||||||||||||||||||||||||||||||||||||||||
| 148 | }; | ||||||||||||||||||||||||||||||||||||||||||||||
| 149 | 2 | ▶ | $conn->loop->defer(sub { _handoff($state) }); | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 150 | |||||||||||||||||||||||||||||||||||||||||||||||
| 151 | 2 | return $transaction; | |||||||||||||||||||||||||||||||||||||||||||||
| 152 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 153 | |||||||||||||||||||||||||||||||||||||||||||||||
| 154 | 2 | ▶ | sub _handoff ($state) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_handoff: called CC=18 SCAR=36.1
| |||||||||||||||||||||||||||||||||||||||||||||||
| 155 | 2 | my $conn = $state->{connection}; | |||||||||||||||||||||||||||||||||||||||||||||
| 156 | 2 | my $transaction = $state->{transaction}; | |||||||||||||||||||||||||||||||||||||||||||||
| 157 | 2 | my $target = $state->{target}; | |||||||||||||||||||||||||||||||||||||||||||||
| 158 | |||||||||||||||||||||||||||||||||||||||||||||||
| 159 | 2 | ▶ | return if !$conn || $conn->is_closed || $conn->{_http_closing}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
not $conn or $conn->is_closed or $conn->{"_http_closing"}
not $conn or $conn->is_closed
MC/DC0%0/3
not $conn or $conn->is_closed or $conn->{"_http_closing"}
not $conn
$conn->is_closed
$conn->{"_http_closing"}
Truth table25%1/4
not(A) or B or C
A= not $connB= $conn->is_closedC= $conn->{"_http_closing"}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 160 | 2 | ▶ | return if !$transaction || $transaction->is_terminal; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
not $transaction or $transaction->is_terminal
MC/DC0%0/2
not $transaction or $transaction->is_terminal
not $transaction
$transaction->is_terminal
Truth table33%1/3
not(A) or B
A= not $transactionB= $transaction->is_terminal
| |||||||||||||||||||||||||||||||||||||||||||||||
| 161 | |||||||||||||||||||||||||||||||||||||||||||||||
| 162 | 2 | ▶ | my $pending = $conn->{_http_pending_upgrade} or return; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 163 | 2 | ▶ | return if refaddr($pending->{transaction}) != refaddr($transaction); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 164 | 2 | ▶ | return if $pending->{target} ne $target; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 165 | |||||||||||||||||||||||||||||||||||||||||||||||
| 166 | 2 | my $active = $conn->{_http_active_transaction}; | |||||||||||||||||||||||||||||||||||||||||||||
| 167 | 2 | ▶ | return if !$active || refaddr($active) != refaddr($transaction); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
not $active or builtin::refaddr($active) != builtin::refaddr($transaction)
MC/DC0%0/2
not $active or builtin::refaddr($active) != builtin::refaddr($transaction)
not $active
builtin::refaddr($active) != builtin::refaddr($transaction)
Truth table33%1/3
not(A) or B
A= not $activeB= builtin::refaddr($active) != builtin::refaddr($transaction)
| |||||||||||||||||||||||||||||||||||||||||||||||
| 168 | |||||||||||||||||||||||||||||||||||||||||||||||
| 169 | 2 | my $request = $transaction->request; | |||||||||||||||||||||||||||||||||||||||||||||
| 170 | 2 | my $response = $transaction->response; | |||||||||||||||||||||||||||||||||||||||||||||
| 171 | 2 | my $request_state = $conn->{_http_request_state}; | |||||||||||||||||||||||||||||||||||||||||||||
| 172 | 2 | ▶ | if (!$request_state || !$request_state->{body_done}) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$request_state and $request_state->{"body_done"}
MC/DC0%0/2
$request_state and $request_state->{"body_done"}
$request_state
$request_state->{"body_done"}
Truth table33%1/3
A and B
A= $request_stateB= $request_state->{"body_done"}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 173 | 0 | $transaction->_clear_upgrade_pending; | |||||||||||||||||||||||||||||||||||||||||||||
| 174 | 0 | delete $conn->{_http_pending_upgrade}; | |||||||||||||||||||||||||||||||||||||||||||||
| 175 | 0 | $conn->_fail_active_transaction(500, $request, $response); | |||||||||||||||||||||||||||||||||||||||||||||
| 176 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||
| 177 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 178 | |||||||||||||||||||||||||||||||||||||||||||||||
| 179 | 2 | my $head; | |||||||||||||||||||||||||||||||||||||||||||||
| 180 | 2 | my $serialized = eval { | |||||||||||||||||||||||||||||||||||||||||||||
| 181 | 2 | $head = $response->_serialize_head('1.1'); | |||||||||||||||||||||||||||||||||||||||||||||
| 182 | 2 | 1; | |||||||||||||||||||||||||||||||||||||||||||||
| 183 | }; | ||||||||||||||||||||||||||||||||||||||||||||||
| 184 | 2 | ▶ | if (!$serialized) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 185 | 0 | $transaction->_clear_upgrade_pending; | |||||||||||||||||||||||||||||||||||||||||||||
| 186 | 0 | delete $conn->{_http_pending_upgrade}; | |||||||||||||||||||||||||||||||||||||||||||||
| 187 | 0 | $conn->_fail_active_transaction(500, $request, $response); | |||||||||||||||||||||||||||||||||||||||||||||
| 188 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||
| 189 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 190 | |||||||||||||||||||||||||||||||||||||||||||||||
| 191 | 2 | $response->_mark_complete; | |||||||||||||||||||||||||||||||||||||||||||||
| 192 | 2 | $transaction->_mark_response_started; | |||||||||||||||||||||||||||||||||||||||||||||
| 193 | 2 | $transaction->_mark_response_output_complete; | |||||||||||||||||||||||||||||||||||||||||||||
| 194 | 2 | $transaction->_clear_upgrade_pending; | |||||||||||||||||||||||||||||||||||||||||||||
| 195 | 2 | $conn->{_http_response_state} = undef; | |||||||||||||||||||||||||||||||||||||||||||||
| 196 | |||||||||||||||||||||||||||||||||||||||||||||||
| 197 | 2 | $conn->write($head); | |||||||||||||||||||||||||||||||||||||||||||||
| 198 | 2 | $conn->_complete_active_transaction_state; | |||||||||||||||||||||||||||||||||||||||||||||
| 199 | |||||||||||||||||||||||||||||||||||||||||||||||
| 200 | 2 | my $input = $conn->{_http_input}; | |||||||||||||||||||||||||||||||||||||||||||||
| 201 | 2 | my $resume_read = $pending->{resume_read}; | |||||||||||||||||||||||||||||||||||||||||||||
| 202 | 2 | $conn->{_http_input} = ''; | |||||||||||||||||||||||||||||||||||||||||||||
| 203 | 2 | delete $conn->{_http_pending_upgrade}; | |||||||||||||||||||||||||||||||||||||||||||||
| 204 | 2 | $conn->_clear_transaction; | |||||||||||||||||||||||||||||||||||||||||||||
| 205 | |||||||||||||||||||||||||||||||||||||||||||||||
| 206 | 2 | my $transitioned = eval { | |||||||||||||||||||||||||||||||||||||||||||||
| 207 | 2 | ▶ | if (length($input)) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 208 | 0 | $conn->transition_to($target, input => $input); | |||||||||||||||||||||||||||||||||||||||||||||
| 209 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 210 | 2 | $conn->transition_to($target); | |||||||||||||||||||||||||||||||||||||||||||||
| 211 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 212 | 2 | ▶ | $conn->resume_read if $resume_read && $conn->is_read_paused; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$resume_read and $conn->is_read_paused
MC/DC0%0/2
$resume_read and $conn->is_read_paused
$resume_read
$conn->is_read_paused
Truth table33%1/3
A and B
A= $resume_readB= $conn->is_read_paused
| |||||||||||||||||||||||||||||||||||||||||||||||
| 213 | 2 | 1; | |||||||||||||||||||||||||||||||||||||||||||||
| 214 | }; | ||||||||||||||||||||||||||||||||||||||||||||||
| 215 | 2 | ▶ | if (!$transitioned) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 216 | 0 | eval { $conn->close; 1 }; | |||||||||||||||||||||||||||||||||||||||||||||
| 217 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 218 | 2 | return; | |||||||||||||||||||||||||||||||||||||||||||||
| 219 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 220 | |||||||||||||||||||||||||||||||||||||||||||||||
| 221 | 0 | ▶ | sub CLONE_SKIP ($class) { 1 } | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
CLONE_SKIP: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||
| 222 | |||||||||||||||||||||||||||||||||||||||||||||||
| 223 | 1 | 1; | |||||||||||||||||||||||||||||||||||||||||||||