| 1 | package Unblock::HTTP3::Body::Reader; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 6 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 6 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||
| 6 | 6 | ▶ | use Carp qw(croak); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | 6 | ▶ | use Scalar::Util qw(blessed weaken); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||
| 9 | 6 | ▶ | use Unblock::HTTP3 (); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 10 | 6 | ▶ | use Unblock::HTTP3::_Bytes (); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||
| 12 | 6 | our $VERSION = '0.13'; | |||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||
| 14 | 26 | ▶ | sub _new { | ||||||||||||||||||||||||||
|
Subroutine
_new: called CC=9 SCAR=23.5
| |||||||||||||||||||||||||||||
| 15 | 26 | my ($class, $transaction, $kind, %option) = @_; | |||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||
| 17 | 26 | ▶ | croak 'body reader kind must be request or response' | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$kind ne "request" and $kind ne "response"
MC/DC0%0/2
$kind ne "request" and $kind ne "response"
$kind ne "request"
$kind ne "response"
Truth table66%2/3
A and B
A= $kind ne "request"B= $kind ne "response"
| |||||||||||||||||||||||||||||
| 18 | if $kind ne 'request' && $kind ne 'response'; | ||||||||||||||||||||||||||||
| 19 | 26 | ▶ | croak 'body reader requires a Unblock::HTTP3::Transaction' | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
builtin::blessed($transaction) and $transaction->isa("Unblock::HTTP3::Transaction")
MC/DC0%0/2
builtin::blessed($transaction) and $transaction->isa("Unblock::HTTP3::Transaction")
builtin::blessed($transaction)
$transaction->isa("Unblock::HTTP3::Transaction")
Truth table33%1/3
A and B
A= builtin::blessed($transaction)B= $transaction->isa("Unblock::HTTP3::Transaction")
| |||||||||||||||||||||||||||||
| 20 | unless blessed($transaction) | ||||||||||||||||||||||||||||
| 21 | && $transaction->isa('Unblock::HTTP3::Transaction'); | ||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||
| 23 | 26 | my $on_data = delete $option{on_data}; | |||||||||||||||||||||||||||
| 24 | 26 | my $on_end = delete $option{on_end}; | |||||||||||||||||||||||||||
| 25 | 26 | my $on_cancel = delete $option{on_cancel}; | |||||||||||||||||||||||||||
| 26 | 26 | my $operation = $kind . '_body'; | |||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||
| 28 | 26 | for my $callback ( | |||||||||||||||||||||||||||
| 29 | [ on_data => $on_data ], | ||||||||||||||||||||||||||||
| 30 | [ on_end => $on_end ], | ||||||||||||||||||||||||||||
| 31 | [ on_cancel => $on_cancel ], | ||||||||||||||||||||||||||||
| 32 | ) { | ||||||||||||||||||||||||||||
| 33 | 78 | ▶ | croak "$operation(): $callback->[0] must be a coderef" | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $callback->[1] and ref $callback->[1] ne "CODE"
MC/DC0%0/2
defined $callback->[1] and ref $callback->[1] ne "CODE"
defined $callback->[1]
ref $callback->[1] ne "CODE"
Truth table66%2/3
A and B
A= defined $callback->[1]B= ref $callback->[1] ne "CODE"
| |||||||||||||||||||||||||||||
| 34 | if defined($callback->[1]) && ref($callback->[1]) ne 'CODE'; | ||||||||||||||||||||||||||||
| 35 | } | ||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||
| 37 | 26 | ▶ | croak "$operation(): unknown option: " . join(', ', sort keys %option) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 38 | if %option; | ||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||
| 40 | 26 | my $self = bless { | |||||||||||||||||||||||||||
| 41 | transaction => $transaction, | ||||||||||||||||||||||||||||
| 42 | kind => $kind, | ||||||||||||||||||||||||||||
| 43 | queue => [], | ||||||||||||||||||||||||||||
| 44 | pending => 0, | ||||||||||||||||||||||||||||
| 45 | ended => 0, | ||||||||||||||||||||||||||||
| 46 | complete => 0, | ||||||||||||||||||||||||||||
| 47 | cancelled => 0, | ||||||||||||||||||||||||||||
| 48 | on_data => $on_data, | ||||||||||||||||||||||||||||
| 49 | on_end => $on_end, | ||||||||||||||||||||||||||||
| 50 | on_cancel => $on_cancel, | ||||||||||||||||||||||||||||
| 51 | delivering => 0, | ||||||||||||||||||||||||||||
| 52 | }, $class; | ||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||
| 54 | 26 | weaken($self->{transaction}); | |||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||
| 56 | 26 | return $self; | |||||||||||||||||||||||||||
| 57 | } | ||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||
| 59 | 4 | ▶ | sub _configure { | ||||||||||||||||||||||||||
|
Subroutine
_configure: called CC=15 SCAR=34.5
| |||||||||||||||||||||||||||||
| 60 | 4 | my ($self, %option) = @_; | |||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||
| 62 | 4 | my $operation = $self->{kind} . '_body'; | |||||||||||||||||||||||||||
| 63 | 4 | my $was_complete = $self->{complete}; | |||||||||||||||||||||||||||
| 64 | 4 | my $was_cancelled = $self->{cancelled}; | |||||||||||||||||||||||||||
| 65 | 4 | my $added_on_end = 0; | |||||||||||||||||||||||||||
| 66 | 4 | my $added_on_cancel = 0; | |||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||
| 68 | 4 | for my $name (qw(on_data on_end on_cancel)) { | |||||||||||||||||||||||||||
| 69 | 12 | ▶ | next unless exists $option{$name}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||
| 71 | 9 | my $callback = delete $option{$name}; | |||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||
| 73 | 9 | ▶ | croak "$operation(): $name must be a coderef" | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $callback and ref $callback ne "CODE"
MC/DC0%0/2
defined $callback and ref $callback ne "CODE"
defined $callback
ref $callback ne "CODE"
Truth table33%1/3
A and B
A= defined $callbackB= ref $callback ne "CODE"
| |||||||||||||||||||||||||||||
| 74 | if defined($callback) && ref($callback) ne 'CODE'; | ||||||||||||||||||||||||||||
| 75 | croak "$operation(): $name is already configured" | ||||||||||||||||||||||||||||
| 76 | 9 | ▶ | if defined($self->{$name}); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||
| 78 | 9 | $self->{$name} = $callback; | |||||||||||||||||||||||||||
| 79 | 9 | ▶ | $added_on_end = 1 if $name eq 'on_end'; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 80 | 9 | ▶ | $added_on_cancel = 1 if $name eq 'on_cancel'; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 81 | } | ||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||
| 83 | 4 | ▶ | croak "$operation(): unknown option: " . join(', ', sort keys %option) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 84 | if %option; | ||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||
| 86 | 4 | ▶ | if ($was_cancelled) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 87 | 0 | my $callback = $self->{on_cancel}; | |||||||||||||||||||||||||||
| 88 | 0 | ▶ | $callback->($self) if $added_on_cancel && $callback; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$added_on_cancel and $callback
MC/DC0%0/2
$added_on_cancel and $callback
$added_on_cancel
$callback
Truth table0%0/3
A and B
A= $added_on_cancelB= $callback
| |||||||||||||||||||||||||||||
| 89 | 0 | return $self; | |||||||||||||||||||||||||||
| 90 | } | ||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||
| 92 | 4 | ▶ | if ($was_complete) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 93 | 0 | my $callback = $self->{on_end}; | |||||||||||||||||||||||||||
| 94 | 0 | ▶ | $callback->($self) if $added_on_end && $callback; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$added_on_end and $callback
MC/DC0%0/2
$added_on_end and $callback
$added_on_end
$callback
Truth table0%0/3
A and B
A= $added_on_endB= $callback
| |||||||||||||||||||||||||||||
| 95 | 0 | return $self; | |||||||||||||||||||||||||||
| 96 | } | ||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||
| 98 | 4 | $self->_deliver_callbacks; | |||||||||||||||||||||||||||
| 99 | 4 | $self->_maybe_finish; | |||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||
| 101 | 4 | return $self; | |||||||||||||||||||||||||||
| 102 | } | ||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||
| 104 | 46 | ▶ | sub pending_bytes { | ||||||||||||||||||||||||||
|
Subroutine
pending_bytes: called CC=2 SCAR=7.1
Pod
documented
| |||||||||||||||||||||||||||||
| 105 | 46 | my ($self, @args) = @_; | |||||||||||||||||||||||||||
| 106 | 46 | ▶ | croak 'pending_bytes() does not accept arguments' if @args; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 107 | 46 | return $self->{pending}; | |||||||||||||||||||||||||||
| 108 | } | ||||||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||||||
| 110 | 65 | ▶ | sub is_complete { | ||||||||||||||||||||||||||
|
Subroutine
is_complete: called CC=3 SCAR=11.1
Pod
documented
| |||||||||||||||||||||||||||||
| 111 | 65 | my ($self, @args) = @_; | |||||||||||||||||||||||||||
| 112 | 65 | ▶ | croak 'is_complete() does not accept arguments' if @args; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 113 | 65 | ▶ | return $self->{complete} ? 1 : 0; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 114 | } | ||||||||||||||||||||||||||||
| 115 | |||||||||||||||||||||||||||||
| 116 | 1 | ▶ | sub is_cancelled { | ||||||||||||||||||||||||||
|
Subroutine
is_cancelled: called CC=3 SCAR=11.7
Pod
documented
| |||||||||||||||||||||||||||||
| 117 | 1 | my ($self, @args) = @_; | |||||||||||||||||||||||||||
| 118 | 1 | ▶ | croak 'is_cancelled() does not accept arguments' if @args; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 119 | 1 | ▶ | return $self->{cancelled} ? 1 : 0; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 120 | } | ||||||||||||||||||||||||||||
| 121 | |||||||||||||||||||||||||||||
| 122 | 18 | ▶ | sub next_chunk { | ||||||||||||||||||||||||||
|
Subroutine
next_chunk: called CC=6 SCAR=18.3
Pod
documented
| |||||||||||||||||||||||||||||
| 123 | 18 | my ($self, @args) = @_; | |||||||||||||||||||||||||||
| 124 | |||||||||||||||||||||||||||||
| 125 | 18 | ▶ | croak 'next_chunk() does not accept arguments' if @args; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 126 | croak 'next_chunk() cannot be called from on_data' | ||||||||||||||||||||||||||||
| 127 | 18 | ▶ | if $self->{delivering}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 128 | 18 | ▶ | return if $self->{cancelled}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 129 | |||||||||||||||||||||||||||||
| 130 | 18 | my $bytes = shift @{ $self->{queue} }; | |||||||||||||||||||||||||||
| 131 | 18 | ▶ | if (defined $bytes) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 132 | 10 | $self->{pending} -= length($bytes); | |||||||||||||||||||||||||||
| 133 | |||||||||||||||||||||||||||||
| 134 | my $transaction = $self->{transaction} | ||||||||||||||||||||||||||||
| 135 | 10 | ▶ | or croak 'next_chunk(): HTTP/3 Transaction is no longer available'; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 136 | |||||||||||||||||||||||||||||
| 137 | $transaction->_consume_received_body( | ||||||||||||||||||||||||||||
| 138 | $self->{kind}, | ||||||||||||||||||||||||||||
| 139 | 10 | length($bytes), | |||||||||||||||||||||||||||
| 140 | ); | ||||||||||||||||||||||||||||
| 141 | } | ||||||||||||||||||||||||||||
| 142 | |||||||||||||||||||||||||||||
| 143 | 18 | $self->_maybe_finish; | |||||||||||||||||||||||||||
| 144 | 18 | return $bytes; | |||||||||||||||||||||||||||
| 145 | } | ||||||||||||||||||||||||||||
| 146 | |||||||||||||||||||||||||||||
| 147 | 0 | ▶ | sub _push { | ||||||||||||||||||||||||||
|
Subroutine
_push: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||
| 148 | 0 | my ($self, $bytes) = @_; | |||||||||||||||||||||||||||
| 149 | |||||||||||||||||||||||||||||
| 150 | 0 | ▶ | return if $self->{cancelled}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 151 | |||||||||||||||||||||||||||||
| 152 | 0 | $bytes = Unblock::HTTP3::_Bytes::byte_string( | |||||||||||||||||||||||||||
| 153 | 'received body', | ||||||||||||||||||||||||||||
| 154 | $bytes, | ||||||||||||||||||||||||||||
| 155 | ); | ||||||||||||||||||||||||||||
| 156 | |||||||||||||||||||||||||||||
| 157 | 0 | return $self->_push_owned($bytes); | |||||||||||||||||||||||||||
| 158 | } | ||||||||||||||||||||||||||||
| 159 | |||||||||||||||||||||||||||||
| 160 | 35 | ▶ | sub _push_owned { | ||||||||||||||||||||||||||
|
Subroutine
_push_owned: called CC=3 SCAR=11.1
| |||||||||||||||||||||||||||||
| 161 | 35 | my ($self, $bytes) = @_; | |||||||||||||||||||||||||||
| 162 | |||||||||||||||||||||||||||||
| 163 | 35 | ▶ | return if $self->{cancelled}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 164 | |||||||||||||||||||||||||||||
| 165 | 35 | ▶ | if (length $bytes) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 166 | 35 | push @{ $self->{queue} }, $bytes; | |||||||||||||||||||||||||||
| 167 | 35 | $self->{pending} += length($bytes); | |||||||||||||||||||||||||||
| 168 | } | ||||||||||||||||||||||||||||
| 169 | |||||||||||||||||||||||||||||
| 170 | 35 | $self->_deliver_callbacks; | |||||||||||||||||||||||||||
| 171 | 34 | return; | |||||||||||||||||||||||||||
| 172 | } | ||||||||||||||||||||||||||||
| 173 | |||||||||||||||||||||||||||||
| 174 | 18 | ▶ | sub _mark_end { | ||||||||||||||||||||||||||
|
Subroutine
_mark_end: called CC=2 SCAR=7.0
| |||||||||||||||||||||||||||||
| 175 | 18 | my ($self) = @_; | |||||||||||||||||||||||||||
| 176 | |||||||||||||||||||||||||||||
| 177 | 18 | ▶ | return if $self->{cancelled}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 178 | |||||||||||||||||||||||||||||
| 179 | 18 | $self->{ended} = 1; | |||||||||||||||||||||||||||
| 180 | 18 | $self->_deliver_callbacks; | |||||||||||||||||||||||||||
| 181 | 18 | $self->_maybe_finish; | |||||||||||||||||||||||||||
| 182 | |||||||||||||||||||||||||||||
| 183 | 18 | return; | |||||||||||||||||||||||||||
| 184 | } | ||||||||||||||||||||||||||||
| 185 | |||||||||||||||||||||||||||||
| 186 | 57 | ▶ | sub _deliver_callbacks { | ||||||||||||||||||||||||||
|
Subroutine
_deliver_callbacks: called CC=7 SCAR=19.5
| |||||||||||||||||||||||||||||
| 187 | 57 | my ($self) = @_; | |||||||||||||||||||||||||||
| 188 | |||||||||||||||||||||||||||||
| 189 | 57 | ▶ | my $callback = $self->{on_data} or return; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 190 | |||||||||||||||||||||||||||||
| 191 | 31 | ▶ | while (!$self->{cancelled} && @{ $self->{queue} }) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
not $self->{"cancelled"} and @{$self->{"queue"};}
MC/DC50%1/2
not $self->{"cancelled"} and @{$self->{"queue"};}
not $self->{"cancelled"}
@{$self->{"queue"};}
Truth table66%2/3
not(A) and B
A= not $self->{"cancelled"}B= @{$self->{"queue"};}
| |||||||||||||||||||||||||||||
| 192 | 21 | my $bytes = $self->{queue}[0]; | |||||||||||||||||||||||||||
| 193 | |||||||||||||||||||||||||||||
| 194 | 21 | $self->{delivering} = 1; | |||||||||||||||||||||||||||
| 195 | |||||||||||||||||||||||||||||
| 196 | 21 | my ($ok, $error); | |||||||||||||||||||||||||||
| 197 | { | ||||||||||||||||||||||||||||
| 198 | 21 | local $@; | |||||||||||||||||||||||||||
| 199 | 21 | $ok = eval { | |||||||||||||||||||||||||||
| 200 | 21 | $callback->($self, $bytes); | |||||||||||||||||||||||||||
| 201 | 20 | 1; | |||||||||||||||||||||||||||
| 202 | }; | ||||||||||||||||||||||||||||
| 203 | 21 | $error = $@; | |||||||||||||||||||||||||||
| 204 | } | ||||||||||||||||||||||||||||
| 205 | |||||||||||||||||||||||||||||
| 206 | 21 | $self->{delivering} = 0; | |||||||||||||||||||||||||||
| 207 | |||||||||||||||||||||||||||||
| 208 | 21 | ▶ | die $error unless $ok; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 209 | 20 | ▶ | return if $self->{cancelled}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 210 | |||||||||||||||||||||||||||||
| 211 | 19 | shift @{ $self->{queue} }; | |||||||||||||||||||||||||||
| 212 | 19 | $self->{pending} -= length($bytes); | |||||||||||||||||||||||||||
| 213 | |||||||||||||||||||||||||||||
| 214 | my $transaction = $self->{transaction} | ||||||||||||||||||||||||||||
| 215 | 19 | ▶ | or croak 'body callback lost its HTTP/3 Transaction'; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 216 | |||||||||||||||||||||||||||||
| 217 | $transaction->_consume_received_body( | ||||||||||||||||||||||||||||
| 218 | $self->{kind}, | ||||||||||||||||||||||||||||
| 219 | 19 | length($bytes), | |||||||||||||||||||||||||||
| 220 | ); | ||||||||||||||||||||||||||||
| 221 | } | ||||||||||||||||||||||||||||
| 222 | |||||||||||||||||||||||||||||
| 223 | 29 | $self->_maybe_finish; | |||||||||||||||||||||||||||
| 224 | 29 | return; | |||||||||||||||||||||||||||
| 225 | } | ||||||||||||||||||||||||||||
| 226 | |||||||||||||||||||||||||||||
| 227 | 69 | ▶ | sub _maybe_finish { | ||||||||||||||||||||||||||
|
Subroutine
_maybe_finish: called CC=16 SCAR=30.5
| |||||||||||||||||||||||||||||
| 228 | 69 | my ($self) = @_; | |||||||||||||||||||||||||||
| 229 | |||||||||||||||||||||||||||||
| 230 | 69 | ▶ | return if $self->{complete} || $self->{cancelled}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$self->{"complete"} or $self->{"cancelled"}
MC/DC50%1/2
$self->{"complete"} or $self->{"cancelled"}
$self->{"complete"}
$self->{"cancelled"}
Truth table66%2/3
A or B
A= $self->{"complete"}B= $self->{"cancelled"}
| |||||||||||||||||||||||||||||
| 231 | 61 | ▶ | return unless $self->{ended}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 232 | 22 | ▶ | return if @{ $self->{queue} }; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 233 | |||||||||||||||||||||||||||||
| 234 | 18 | $self->{complete} = 1; | |||||||||||||||||||||||||||
| 235 | |||||||||||||||||||||||||||||
| 236 | 18 | my $transaction = $self->{transaction}; | |||||||||||||||||||||||||||
| 237 | 18 | ▶ | $transaction->{callback_depth}++ if $transaction; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 238 | 18 | my $ok = eval { | |||||||||||||||||||||||||||
| 239 | $transaction->_received_body_complete($self->{kind}) | ||||||||||||||||||||||||||||
| 240 | 18 | ▶ | if $transaction; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 241 | 18 | my $callback = $self->{on_end}; | |||||||||||||||||||||||||||
| 242 | 18 | ▶ | $callback->($self) if $callback; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 243 | 18 | 1; | |||||||||||||||||||||||||||
| 244 | }; | ||||||||||||||||||||||||||||
| 245 | 18 | my $error = "$@"; | |||||||||||||||||||||||||||
| 246 | 18 | ▶ | if ($transaction) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 247 | 18 | $transaction->{callback_depth}--; | |||||||||||||||||||||||||||
| 248 | 18 | ▶ | if (!$ok && !$transaction->is_terminal) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$ok or $transaction->is_terminal
MC/DC0%0/2
$ok or $transaction->is_terminal
$ok
$transaction->is_terminal
Truth table33%1/3
A or B
A= $okB= $transaction->is_terminal
| |||||||||||||||||||||||||||||
| 249 | 0 | my $connection = $transaction->{connection}; | |||||||||||||||||||||||||||
| 250 | 0 | ▶ | $connection->_reject_message_stream($transaction->stream_id, $error) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 251 | if $connection; | ||||||||||||||||||||||||||||
| 252 | 0 | eval { $transaction->_mark_error($error) }; | |||||||||||||||||||||||||||
| 253 | } | ||||||||||||||||||||||||||||
| 254 | 18 | ▶ | $transaction->_notify_finish if $transaction->{finish_pending}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 255 | 18 | ▶ | if ($ok) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 256 | 18 | my $connection = $transaction->{connection}; | |||||||||||||||||||||||||||
| 257 | 18 | ▶ | $connection->_maybe_complete_transaction($transaction->stream_id) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 258 | if $connection; | ||||||||||||||||||||||||||||
| 259 | } | ||||||||||||||||||||||||||||
| 260 | } | ||||||||||||||||||||||||||||
| 261 | 18 | ▶ | die $error unless $ok; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 262 | |||||||||||||||||||||||||||||
| 263 | 18 | return; | |||||||||||||||||||||||||||
| 264 | } | ||||||||||||||||||||||||||||
| 265 | |||||||||||||||||||||||||||||
| 266 | 8 | ▶ | sub _cancel { | ||||||||||||||||||||||||||
|
Subroutine
_cancel: called CC=6 SCAR=18.2
| |||||||||||||||||||||||||||||
| 267 | 8 | my ($self) = @_; | |||||||||||||||||||||||||||
| 268 | |||||||||||||||||||||||||||||
| 269 | 8 | ▶ | return if $self->{complete} || $self->{cancelled}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$self->{"complete"} or $self->{"cancelled"}
MC/DC0%0/2
$self->{"complete"} or $self->{"cancelled"}
$self->{"complete"}
$self->{"cancelled"}
Truth table33%1/3
A or B
A= $self->{"complete"}B= $self->{"cancelled"}
| |||||||||||||||||||||||||||||
| 270 | |||||||||||||||||||||||||||||
| 271 | 8 | $self->{cancelled} = 1; | |||||||||||||||||||||||||||
| 272 | 8 | my $pending = $self->{pending}; | |||||||||||||||||||||||||||
| 273 | 8 | $self->{queue} = []; | |||||||||||||||||||||||||||
| 274 | 8 | $self->{pending} = 0; | |||||||||||||||||||||||||||
| 275 | 8 | my $transaction = $self->{transaction}; | |||||||||||||||||||||||||||
| 276 | 8 | ▶ | $transaction->_consume_received_body($self->{kind}, $pending) | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$transaction and $pending
MC/DC50%1/2
$transaction and $pending
$transaction
$pending
Truth table66%2/3
A and B
A= $transactionB= $pending
| |||||||||||||||||||||||||||||
| 277 | if $transaction && $pending; | ||||||||||||||||||||||||||||
| 278 | |||||||||||||||||||||||||||||
| 279 | 8 | my $callback = $self->{on_cancel}; | |||||||||||||||||||||||||||
| 280 | 8 | ▶ | $callback->($self) if $callback; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 281 | |||||||||||||||||||||||||||||
| 282 | 8 | return; | |||||||||||||||||||||||||||
| 283 | } | ||||||||||||||||||||||||||||
| 284 | |||||||||||||||||||||||||||||
| 285 | 89 | ▶ | sub _drain { | ||||||||||||||||||||||||||
|
Subroutine
_drain: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 286 | 89 | return; | |||||||||||||||||||||||||||
| 287 | } | ||||||||||||||||||||||||||||
| 288 | |||||||||||||||||||||||||||||
| 289 | 6 | 1; | |||||||||||||||||||||||||||
| 290 | |||||||||||||||||||||||||||||
| 291 | __END__ | ||||||||||||||||||||||||||||