| 1 | package Unblock::HTTP3::Extension::Stream; | ||||||||||||||||||||||||||||||||||||||||
| 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 | |||||||||||||||||||||||||||||||||||||||||
| 6 | 2 | ▶ | use Carp qw(croak); | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||
| 7 | 2 | ▶ | use Scalar::Util qw(blessed weaken); | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||||||||||
| 9 | 2 | ▶ | use Unblock::HTTP3 (); | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||
| 10 | 2 | ▶ | use Unblock::HTTP3::_Bytes (); | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||||||||||
| 12 | 2 | our $VERSION = '0.14'; | |||||||||||||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||||||||||||||
| 14 | 5 | ▶ | sub _new { | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
_new: called CC=13 SCAR=28.4
| |||||||||||||||||||||||||||||||||||||||||
| 15 | 5 | my ($class, %args) = @_; | |||||||||||||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||||||||||||||
| 17 | 5 | my $connection = delete $args{connection}; | |||||||||||||||||||||||||||||||||||||||
| 18 | 5 | my $stream = delete $args{stream}; | |||||||||||||||||||||||||||||||||||||||
| 19 | 5 | my $type = delete $args{type}; | |||||||||||||||||||||||||||||||||||||||
| 20 | 5 | my $header_length = delete $args{header_length}; | |||||||||||||||||||||||||||||||||||||||
| 21 | 5 | my $incoming = delete $args{incoming}; | |||||||||||||||||||||||||||||||||||||||
| 22 | 5 | my $initial = delete $args{initial}; | |||||||||||||||||||||||||||||||||||||||
| 23 | 5 | my $initial_fin = delete $args{initial_fin}; | |||||||||||||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||||||||||||||
| 25 | 5 | ▶ | croak 'extension stream requires a Unblock::HTTP3::Connection' | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
builtin::blessed($connection) and $connection->isa("Unblock::HTTP3::Connection")
MC/DC0%0/2
builtin::blessed($connection) and $connection->isa("Unblock::HTTP3::Connection")
builtin::blessed($connection)
$connection->isa("Unblock::HTTP3::Connection")
Truth table33%1/3
A and B
A= builtin::blessed($connection)B= $connection->isa("Unblock::HTTP3::Connection")
| |||||||||||||||||||||||||||||||||||||||||
| 26 | unless blessed($connection) | ||||||||||||||||||||||||||||||||||||||||
| 27 | && $connection->isa('Unblock::HTTP3::Connection'); | ||||||||||||||||||||||||||||||||||||||||
| 28 | 5 | ▶ | croak 'extension stream requires a Net::QUIC::Stream' | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
builtin::blessed($stream) and $stream->isa("Net::QUIC::Stream")
MC/DC0%0/2
builtin::blessed($stream) and $stream->isa("Net::QUIC::Stream")
builtin::blessed($stream)
$stream->isa("Net::QUIC::Stream")
Truth table33%1/3
A and B
A= builtin::blessed($stream)B= $stream->isa("Net::QUIC::Stream")
| |||||||||||||||||||||||||||||||||||||||||
| 29 | unless blessed($stream) | ||||||||||||||||||||||||||||||||||||||||
| 30 | && $stream->isa('Net::QUIC::Stream'); | ||||||||||||||||||||||||||||||||||||||||
| 31 | 5 | ▶ | croak 'extension stream type is required' | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 32 | unless defined $type; | ||||||||||||||||||||||||||||||||||||||||
| 33 | 5 | ▶ | croak 'unknown extension stream option: ' . join(', ', sort keys %args) | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 34 | if %args; | ||||||||||||||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||||||||||||||
| 36 | 5 | ▶ | $header_length = 0 unless defined $header_length; | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 37 | 5 | ▶ | $initial = '' unless defined $initial; | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 38 | 5 | ▶ | $initial_fin = $initial_fin ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||||||||||||||
| 40 | 5 | ▶ | my $self = bless { | ||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition33%1/3
length $initial or $initial_fin
MC/DC0%0/2
length $initial or $initial_fin
length $initial
$initial_fin
Truth table33%1/3
A or B
A= length $initialB= $initial_fin
| |||||||||||||||||||||||||||||||||||||||||
| 41 | connection => $connection, | ||||||||||||||||||||||||||||||||||||||||
| 42 | stream => $stream, | ||||||||||||||||||||||||||||||||||||||||
| 43 | type => "$type", | ||||||||||||||||||||||||||||||||||||||||
| 44 | header_length => 0 + $header_length, | ||||||||||||||||||||||||||||||||||||||||
| 45 | incoming => $incoming ? 1 : 0, | ||||||||||||||||||||||||||||||||||||||||
| 46 | initial => length($initial) || $initial_fin | ||||||||||||||||||||||||||||||||||||||||
| 47 | ? [ $initial, $initial_fin ] | ||||||||||||||||||||||||||||||||||||||||
| 48 | : undef, | ||||||||||||||||||||||||||||||||||||||||
| 49 | on_data => undef, | ||||||||||||||||||||||||||||||||||||||||
| 50 | on_end => undef, | ||||||||||||||||||||||||||||||||||||||||
| 51 | on_reset => undef, | ||||||||||||||||||||||||||||||||||||||||
| 52 | on_stop => undef, | ||||||||||||||||||||||||||||||||||||||||
| 53 | on_drain => undef, | ||||||||||||||||||||||||||||||||||||||||
| 54 | ended => 0, | ||||||||||||||||||||||||||||||||||||||||
| 55 | reset_code => undef, | ||||||||||||||||||||||||||||||||||||||||
| 56 | stop_code => undef, | ||||||||||||||||||||||||||||||||||||||||
| 57 | flow_blocked => 0, | ||||||||||||||||||||||||||||||||||||||||
| 58 | }, $class; | ||||||||||||||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||||||||||||||
| 60 | 5 | weaken($self->{connection}); | |||||||||||||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||||||||||||||
| 62 | 5 | return $self; | |||||||||||||||||||||||||||||||||||||||
| 63 | } | ||||||||||||||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||||||||||||||
| 65 | 2 | ▶ | sub type { | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
type: called CC=2 SCAR=7.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||
| 66 | 2 | my ($self, @args) = @_; | |||||||||||||||||||||||||||||||||||||||
| 67 | 2 | ▶ | croak 'type() does not accept arguments' if @args; | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 68 | 2 | return $self->{type}; | |||||||||||||||||||||||||||||||||||||||
| 69 | } | ||||||||||||||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||||||||||||||
| 71 | 0 | ▶ | sub id { | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
id: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||
| 72 | 0 | my ($self, @args) = @_; | |||||||||||||||||||||||||||||||||||||||
| 73 | 0 | ▶ | croak 'id() does not accept arguments' if @args; | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 74 | 0 | return $self->{stream}->id; | |||||||||||||||||||||||||||||||||||||||
| 75 | } | ||||||||||||||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||||||||||||||
| 77 | 1 | ▶ | sub incoming { | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
incoming: called CC=3 SCAR=11.7
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||
| 78 | 1 | my ($self, @args) = @_; | |||||||||||||||||||||||||||||||||||||||
| 79 | 1 | ▶ | croak 'incoming() does not accept arguments' if @args; | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 80 | 1 | ▶ | return $self->{incoming} ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 81 | } | ||||||||||||||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||||||||||||||
| 83 | 1 | ▶ | sub can_send { | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
can_send: called CC=3 SCAR=11.7
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||
| 84 | 1 | my ($self, @args) = @_; | |||||||||||||||||||||||||||||||||||||||
| 85 | 1 | ▶ | croak 'can_send() does not accept arguments' if @args; | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 86 | 1 | ▶ | return $self->{stream}->can_send ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 87 | } | ||||||||||||||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||||||||||||||
| 89 | 1 | ▶ | sub can_receive { | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
can_receive: called CC=3 SCAR=11.7
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||
| 90 | 1 | my ($self, @args) = @_; | |||||||||||||||||||||||||||||||||||||||
| 91 | 1 | ▶ | croak 'can_receive() does not accept arguments' if @args; | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 92 | 1 | ▶ | return $self->{stream}->can_receive ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 93 | } | ||||||||||||||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||||||||||||||
| 95 | 1 | ▶ | sub configure { | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
configure: called CC=17 SCAR=37.7
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||
| 96 | 1 | my ($self, %option) = @_; | |||||||||||||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||||||||||||||
| 98 | 1 | for my $name (qw(on_data on_end on_reset on_stop on_drain)) { | |||||||||||||||||||||||||||||||||||||||
| 99 | 5 | ▶ | next unless exists $option{$name}; | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||||||||||||||
| 101 | 2 | my $callback = delete $option{$name}; | |||||||||||||||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||||||||||||||||
| 103 | 2 | ▶ | croak "configure(): $name must be a code reference" | ||||||||||||||||||||||||||||||||||||||
|
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"
| |||||||||||||||||||||||||||||||||||||||||
| 104 | if defined($callback) && ref($callback) ne 'CODE'; | ||||||||||||||||||||||||||||||||||||||||
| 105 | croak "configure(): $name is already configured" | ||||||||||||||||||||||||||||||||||||||||
| 106 | 2 | ▶ | if defined($self->{$name}); | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||||||||||||||
| 108 | 2 | ▶ | if ($name eq 'on_drain') { | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 109 | croak 'configure(): on_drain requires an outgoing stream' | ||||||||||||||||||||||||||||||||||||||||
| 110 | 0 | ▶ | unless $self->{stream}->can_send; | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 111 | } else { | ||||||||||||||||||||||||||||||||||||||||
| 112 | croak "configure(): $name requires an incoming stream" | ||||||||||||||||||||||||||||||||||||||||
| 113 | 2 | ▶ | unless $self->{stream}->can_receive; | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 114 | } | ||||||||||||||||||||||||||||||||||||||||
| 115 | |||||||||||||||||||||||||||||||||||||||||
| 116 | 2 | $self->{$name} = $callback; | |||||||||||||||||||||||||||||||||||||||
| 117 | } | ||||||||||||||||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||||||||||||||
| 119 | 1 | ▶ | croak 'configure(): unknown option: ' . join(', ', sort keys %option) | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 120 | if %option; | ||||||||||||||||||||||||||||||||||||||||
| 121 | |||||||||||||||||||||||||||||||||||||||||
| 122 | 1 | ▶ | if (defined($self->{reset_code}) && defined($self->{on_reset})) { | ||||||||||||||||||||||||||||||||||||||
|
Branch: 4 branches
Condition33%1/3
defined $self->{"reset_code"} and defined $self->{"on_reset"}
MC/DC0%0/2
defined $self->{"reset_code"} and defined $self->{"on_reset"}
defined $self->{"reset_code"}
defined $self->{"on_reset"}
Truth table33%1/3
A and B
A= defined $self->{"reset_code"}B= defined $self->{"on_reset"}
| |||||||||||||||||||||||||||||||||||||||||
| 123 | 0 | $self->{on_reset}->($self, $self->{reset_code}); | |||||||||||||||||||||||||||||||||||||||
| 124 | ▶ | } elsif (defined($self->{stop_code}) && defined($self->{on_stop})) { | |||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
defined $self->{"stop_code"} and defined $self->{"on_stop"}
MC/DC0%0/2
defined $self->{"stop_code"} and defined $self->{"on_stop"}
defined $self->{"stop_code"}
defined $self->{"on_stop"}
Truth table33%1/3
A and B
A= defined $self->{"stop_code"}B= defined $self->{"on_stop"}
| |||||||||||||||||||||||||||||||||||||||||
| 125 | 0 | $self->{on_stop}->($self, $self->{stop_code}); | |||||||||||||||||||||||||||||||||||||||
| 126 | ▶ | } elsif ($self->{ended} && defined($self->{on_end})) { | |||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$self->{"ended"} and defined $self->{"on_end"}
MC/DC0%0/2
$self->{"ended"} and defined $self->{"on_end"}
$self->{"ended"}
defined $self->{"on_end"}
Truth table33%1/3
A and B
A= $self->{"ended"}B= defined $self->{"on_end"}
| |||||||||||||||||||||||||||||||||||||||||
| 127 | 0 | $self->{on_end}->($self); | |||||||||||||||||||||||||||||||||||||||
| 128 | } elsif (defined $self->{on_data}) { | ||||||||||||||||||||||||||||||||||||||||
| 129 | 1 | $self->_drain_receive; | |||||||||||||||||||||||||||||||||||||||
| 130 | } | ||||||||||||||||||||||||||||||||||||||||
| 131 | |||||||||||||||||||||||||||||||||||||||||
| 132 | 1 | return $self; | |||||||||||||||||||||||||||||||||||||||
| 133 | } | ||||||||||||||||||||||||||||||||||||||||
| 134 | |||||||||||||||||||||||||||||||||||||||||
| 135 | 5 | ▶ | sub next_chunk { | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
next_chunk: called CC=9 SCAR=23.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||
| 136 | 5 | my ($self, @args) = @_; | |||||||||||||||||||||||||||||||||||||||
| 137 | |||||||||||||||||||||||||||||||||||||||||
| 138 | 5 | ▶ | croak 'next_chunk() does not accept arguments' if @args; | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 139 | croak 'next_chunk() cannot be used with on_data' | ||||||||||||||||||||||||||||||||||||||||
| 140 | 5 | ▶ | if defined $self->{on_data}; | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 141 | croak 'cannot receive on this extension stream' | ||||||||||||||||||||||||||||||||||||||||
| 142 | 5 | ▶ | unless $self->{stream}->can_receive; | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 143 | 5 | ▶ | return if defined $self->{reset_code}; | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 144 | |||||||||||||||||||||||||||||||||||||||||
| 145 | 5 | my ($bytes, $fin); | |||||||||||||||||||||||||||||||||||||||
| 146 | |||||||||||||||||||||||||||||||||||||||||
| 147 | 5 | ▶ | if (defined $self->{initial}) { | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 148 | 0 | ($bytes, $fin) = @{ delete $self->{initial} }; | |||||||||||||||||||||||||||||||||||||||
| 149 | } else { | ||||||||||||||||||||||||||||||||||||||||
| 150 | 5 | my $chunk = $self->{stream}->next_data_chunk; | |||||||||||||||||||||||||||||||||||||||
| 151 | 5 | ▶ | return unless defined $chunk; | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 152 | 2 | ($bytes, $fin) = @$chunk; | |||||||||||||||||||||||||||||||||||||||
| 153 | } | ||||||||||||||||||||||||||||||||||||||||
| 154 | |||||||||||||||||||||||||||||||||||||||||
| 155 | 2 | ▶ | $self->{stream}->consume(length($bytes)) | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 156 | if length($bytes); | ||||||||||||||||||||||||||||||||||||||||
| 157 | |||||||||||||||||||||||||||||||||||||||||
| 158 | 2 | ▶ | $self->_mark_end if $fin; | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 159 | |||||||||||||||||||||||||||||||||||||||||
| 160 | 2 | return $bytes; | |||||||||||||||||||||||||||||||||||||||
| 161 | } | ||||||||||||||||||||||||||||||||||||||||
| 162 | |||||||||||||||||||||||||||||||||||||||||
| 163 | 3 | ▶ | sub send { | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
send: called CC=4 SCAR=14.3
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||
| 164 | 3 | my ($self, $bytes) = @_; | |||||||||||||||||||||||||||||||||||||||
| 165 | |||||||||||||||||||||||||||||||||||||||||
| 166 | croak 'cannot send on this extension stream' | ||||||||||||||||||||||||||||||||||||||||
| 167 | 3 | ▶ | unless $self->{stream}->can_send; | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 168 | croak 'extension stream send side is already finished' | ||||||||||||||||||||||||||||||||||||||||
| 169 | 3 | ▶ | if $self->{ended}; | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 170 | croak 'peer stopped the extension stream send side' | ||||||||||||||||||||||||||||||||||||||||
| 171 | 3 | ▶ | if defined $self->{stop_code}; | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 172 | |||||||||||||||||||||||||||||||||||||||||
| 173 | 3 | $bytes = Unblock::HTTP3::_Bytes::byte_string( | |||||||||||||||||||||||||||||||||||||||
| 174 | 'extension stream data', | ||||||||||||||||||||||||||||||||||||||||
| 175 | $bytes, | ||||||||||||||||||||||||||||||||||||||||
| 176 | ); | ||||||||||||||||||||||||||||||||||||||||
| 177 | |||||||||||||||||||||||||||||||||||||||||
| 178 | 3 | $self->{stream}->send($bytes); | |||||||||||||||||||||||||||||||||||||||
| 179 | 3 | return $self; | |||||||||||||||||||||||||||||||||||||||
| 180 | } | ||||||||||||||||||||||||||||||||||||||||
| 181 | |||||||||||||||||||||||||||||||||||||||||
| 182 | 0 | ▶ | sub send_some { | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
send_some: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||
| 183 | 0 | my ($self, $bytes) = @_; | |||||||||||||||||||||||||||||||||||||||
| 184 | |||||||||||||||||||||||||||||||||||||||||
| 185 | croak 'cannot send on this extension stream' | ||||||||||||||||||||||||||||||||||||||||
| 186 | 0 | ▶ | unless $self->{stream}->can_send; | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 187 | croak 'extension stream send side is already finished' | ||||||||||||||||||||||||||||||||||||||||
| 188 | 0 | ▶ | if $self->{ended}; | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 189 | croak 'peer stopped the extension stream send side' | ||||||||||||||||||||||||||||||||||||||||
| 190 | 0 | ▶ | if defined $self->{stop_code}; | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 191 | |||||||||||||||||||||||||||||||||||||||||
| 192 | 0 | $bytes = Unblock::HTTP3::_Bytes::byte_string( | |||||||||||||||||||||||||||||||||||||||
| 193 | 'extension stream data', | ||||||||||||||||||||||||||||||||||||||||
| 194 | $bytes, | ||||||||||||||||||||||||||||||||||||||||
| 195 | ); | ||||||||||||||||||||||||||||||||||||||||
| 196 | |||||||||||||||||||||||||||||||||||||||||
| 197 | 0 | my $accepted = $self->{stream}->send_some($bytes); | |||||||||||||||||||||||||||||||||||||||
| 198 | 0 | ▶ | $self->{flow_blocked} = $accepted < length($bytes) ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 199 | |||||||||||||||||||||||||||||||||||||||||
| 200 | 0 | return $accepted; | |||||||||||||||||||||||||||||||||||||||
| 201 | } | ||||||||||||||||||||||||||||||||||||||||
| 202 | |||||||||||||||||||||||||||||||||||||||||
| 203 | 3 | ▶ | sub finish { | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
finish: called CC=4 SCAR=14.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||
| 204 | 3 | my ($self, @args) = @_; | |||||||||||||||||||||||||||||||||||||||
| 205 | |||||||||||||||||||||||||||||||||||||||||
| 206 | 3 | ▶ | croak 'finish() does not accept arguments' if @args; | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 207 | croak 'cannot finish this incoming extension stream' | ||||||||||||||||||||||||||||||||||||||||
| 208 | 3 | ▶ | unless $self->{stream}->can_send; | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 209 | croak 'extension stream send side is already finished' | ||||||||||||||||||||||||||||||||||||||||
| 210 | 3 | ▶ | if $self->{ended}; | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 211 | |||||||||||||||||||||||||||||||||||||||||
| 212 | 3 | $self->{stream}->finish; | |||||||||||||||||||||||||||||||||||||||
| 213 | 3 | $self->{ended} = 1; | |||||||||||||||||||||||||||||||||||||||
| 214 | 3 | $self->{flow_blocked} = 0; | |||||||||||||||||||||||||||||||||||||||
| 215 | |||||||||||||||||||||||||||||||||||||||||
| 216 | 3 | return $self; | |||||||||||||||||||||||||||||||||||||||
| 217 | } | ||||||||||||||||||||||||||||||||||||||||
| 218 | |||||||||||||||||||||||||||||||||||||||||
| 219 | 0 | ▶ | sub stop_sending { | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
stop_sending: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||
| 220 | 0 | my ($self, $code) = @_; | |||||||||||||||||||||||||||||||||||||||
| 221 | 0 | ▶ | $code = 0 unless defined $code; | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 222 | |||||||||||||||||||||||||||||||||||||||||
| 223 | croak 'cannot stop this outgoing extension stream' | ||||||||||||||||||||||||||||||||||||||||
| 224 | 0 | ▶ | unless $self->{stream}->can_receive; | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 225 | |||||||||||||||||||||||||||||||||||||||||
| 226 | 0 | $self->{stream}->stop_sending($code); | |||||||||||||||||||||||||||||||||||||||
| 227 | 0 | return $self; | |||||||||||||||||||||||||||||||||||||||
| 228 | } | ||||||||||||||||||||||||||||||||||||||||
| 229 | |||||||||||||||||||||||||||||||||||||||||
| 230 | 0 | ▶ | sub reset { | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
reset: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||
| 231 | 0 | my ($self, $code) = @_; | |||||||||||||||||||||||||||||||||||||||
| 232 | 0 | ▶ | $code = 0 unless defined $code; | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 233 | |||||||||||||||||||||||||||||||||||||||||
| 234 | croak 'cannot reset this incoming extension stream' | ||||||||||||||||||||||||||||||||||||||||
| 235 | 0 | ▶ | unless $self->{stream}->can_send; | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 236 | |||||||||||||||||||||||||||||||||||||||||
| 237 | 0 | $self->{stream}->reset($code); | |||||||||||||||||||||||||||||||||||||||
| 238 | 0 | $self->{ended} = 1; | |||||||||||||||||||||||||||||||||||||||
| 239 | 0 | $self->{flow_blocked} = 0; | |||||||||||||||||||||||||||||||||||||||
| 240 | |||||||||||||||||||||||||||||||||||||||||
| 241 | 0 | return $self; | |||||||||||||||||||||||||||||||||||||||
| 242 | } | ||||||||||||||||||||||||||||||||||||||||
| 243 | |||||||||||||||||||||||||||||||||||||||||
| 244 | 0 | ▶ | sub acked_offset { | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
acked_offset: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||
| 245 | 0 | my ($self, @args) = @_; | |||||||||||||||||||||||||||||||||||||||
| 246 | |||||||||||||||||||||||||||||||||||||||||
| 247 | 0 | ▶ | croak 'acked_offset() does not accept arguments' if @args; | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 248 | croak 'acked_offset() is only available for outgoing extension streams' | ||||||||||||||||||||||||||||||||||||||||
| 249 | 0 | ▶ | unless $self->{stream}->can_send; | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 250 | |||||||||||||||||||||||||||||||||||||||||
| 251 | 0 | my $offset = $self->{stream}->acked_offset; | |||||||||||||||||||||||||||||||||||||||
| 252 | 0 | my $header = $self->{header_length}; | |||||||||||||||||||||||||||||||||||||||
| 253 | |||||||||||||||||||||||||||||||||||||||||
| 254 | 0 | ▶ | return 0 if $offset <= $header; | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 255 | 0 | return $offset - $header; | |||||||||||||||||||||||||||||||||||||||
| 256 | } | ||||||||||||||||||||||||||||||||||||||||
| 257 | |||||||||||||||||||||||||||||||||||||||||
| 258 | 4 | ▶ | sub is_complete { | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_complete: called CC=3 SCAR=11.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||
| 259 | 4 | my ($self, @args) = @_; | |||||||||||||||||||||||||||||||||||||||
| 260 | 4 | ▶ | croak 'is_complete() does not accept arguments' if @args; | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 261 | 4 | ▶ | return $self->{ended} ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 262 | } | ||||||||||||||||||||||||||||||||||||||||
| 263 | |||||||||||||||||||||||||||||||||||||||||
| 264 | 0 | ▶ | sub is_reset { | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_reset: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||
| 265 | 0 | my ($self, @args) = @_; | |||||||||||||||||||||||||||||||||||||||
| 266 | 0 | ▶ | croak 'is_reset() does not accept arguments' if @args; | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 267 | 0 | ▶ | return defined($self->{reset_code}) ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 268 | } | ||||||||||||||||||||||||||||||||||||||||
| 269 | |||||||||||||||||||||||||||||||||||||||||
| 270 | 0 | ▶ | sub reset_code { | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
reset_code: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||
| 271 | 0 | my ($self, @args) = @_; | |||||||||||||||||||||||||||||||||||||||
| 272 | 0 | ▶ | croak 'reset_code() does not accept arguments' if @args; | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 273 | 0 | return $self->{reset_code}; | |||||||||||||||||||||||||||||||||||||||
| 274 | } | ||||||||||||||||||||||||||||||||||||||||
| 275 | |||||||||||||||||||||||||||||||||||||||||
| 276 | 0 | ▶ | sub is_stopped { | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_stopped: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||
| 277 | 0 | my ($self, @args) = @_; | |||||||||||||||||||||||||||||||||||||||
| 278 | 0 | ▶ | croak 'is_stopped() does not accept arguments' if @args; | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 279 | 0 | ▶ | return defined($self->{stop_code}) ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 280 | } | ||||||||||||||||||||||||||||||||||||||||
| 281 | |||||||||||||||||||||||||||||||||||||||||
| 282 | 0 | ▶ | sub stop_code { | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
stop_code: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||
| 283 | 0 | my ($self, @args) = @_; | |||||||||||||||||||||||||||||||||||||||
| 284 | 0 | ▶ | croak 'stop_code() does not accept arguments' if @args; | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 285 | 0 | return $self->{stop_code}; | |||||||||||||||||||||||||||||||||||||||
| 286 | } | ||||||||||||||||||||||||||||||||||||||||
| 287 | |||||||||||||||||||||||||||||||||||||||||
| 288 | 11 | ▶ | sub _drain_receive { | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
_drain_receive: called CC=8 SCAR=21.3
| |||||||||||||||||||||||||||||||||||||||||
| 289 | 11 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||
| 290 | |||||||||||||||||||||||||||||||||||||||||
| 291 | 11 | ▶ | my $callback = $self->{on_data} or return; | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 292 | 6 | ▶ | return if $self->{ended} || defined($self->{reset_code}); | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$self->{"ended"} or defined $self->{"reset_code"}
MC/DC0%0/2
$self->{"ended"} or defined $self->{"reset_code"}
$self->{"ended"}
defined $self->{"reset_code"}
Truth table33%1/3
A or B
A= $self->{"ended"}B= defined $self->{"reset_code"}
| |||||||||||||||||||||||||||||||||||||||||
| 293 | |||||||||||||||||||||||||||||||||||||||||
| 294 | 6 | while (1) { | |||||||||||||||||||||||||||||||||||||||
| 295 | 7 | my ($bytes, $fin); | |||||||||||||||||||||||||||||||||||||||
| 296 | |||||||||||||||||||||||||||||||||||||||||
| 297 | 7 | ▶ | if (defined $self->{initial}) { | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 298 | 0 | ($bytes, $fin) = @{ delete $self->{initial} }; | |||||||||||||||||||||||||||||||||||||||
| 299 | } else { | ||||||||||||||||||||||||||||||||||||||||
| 300 | 7 | my $chunk = $self->{stream}->next_data_chunk; | |||||||||||||||||||||||||||||||||||||||
| 301 | 7 | ▶ | last unless defined $chunk; | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 302 | 2 | ($bytes, $fin) = @$chunk; | |||||||||||||||||||||||||||||||||||||||
| 303 | } | ||||||||||||||||||||||||||||||||||||||||
| 304 | |||||||||||||||||||||||||||||||||||||||||
| 305 | 2 | ▶ | if (length $bytes) { | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 306 | 1 | $callback->($self, $bytes); | |||||||||||||||||||||||||||||||||||||||
| 307 | 1 | $self->{stream}->consume(length($bytes)); | |||||||||||||||||||||||||||||||||||||||
| 308 | } | ||||||||||||||||||||||||||||||||||||||||
| 309 | |||||||||||||||||||||||||||||||||||||||||
| 310 | 2 | ▶ | if ($fin) { | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 311 | 1 | $self->_mark_end; | |||||||||||||||||||||||||||||||||||||||
| 312 | 1 | last; | |||||||||||||||||||||||||||||||||||||||
| 313 | } | ||||||||||||||||||||||||||||||||||||||||
| 314 | } | ||||||||||||||||||||||||||||||||||||||||
| 315 | |||||||||||||||||||||||||||||||||||||||||
| 316 | 6 | return; | |||||||||||||||||||||||||||||||||||||||
| 317 | } | ||||||||||||||||||||||||||||||||||||||||
| 318 | |||||||||||||||||||||||||||||||||||||||||
| 319 | 6 | ▶ | sub _drain_send { | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
_drain_send: called CC=4 SCAR=24.2
| |||||||||||||||||||||||||||||||||||||||||
| 320 | 6 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||
| 321 | |||||||||||||||||||||||||||||||||||||||||
| 322 | 6 | ▶ | return unless $self->{flow_blocked}; | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 323 | 0 | ▶ | return if $self->{ended}; | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 324 | |||||||||||||||||||||||||||||||||||||||||
| 325 | 0 | $self->{flow_blocked} = 0; | |||||||||||||||||||||||||||||||||||||||
| 326 | |||||||||||||||||||||||||||||||||||||||||
| 327 | 0 | my $callback = $self->{on_drain}; | |||||||||||||||||||||||||||||||||||||||
| 328 | 0 | ▶ | $callback->($self) if defined $callback; | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 329 | |||||||||||||||||||||||||||||||||||||||||
| 330 | 0 | return; | |||||||||||||||||||||||||||||||||||||||
| 331 | } | ||||||||||||||||||||||||||||||||||||||||
| 332 | |||||||||||||||||||||||||||||||||||||||||
| 333 | 2 | ▶ | sub _mark_end { | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
_mark_end: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||
| 334 | 2 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||
| 335 | |||||||||||||||||||||||||||||||||||||||||
| 336 | 2 | ▶ | return if $self->{ended}; | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 337 | |||||||||||||||||||||||||||||||||||||||||
| 338 | 2 | $self->{ended} = 1; | |||||||||||||||||||||||||||||||||||||||
| 339 | |||||||||||||||||||||||||||||||||||||||||
| 340 | 2 | my $callback = $self->{on_end}; | |||||||||||||||||||||||||||||||||||||||
| 341 | 2 | ▶ | $callback->($self) if defined $callback; | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 342 | |||||||||||||||||||||||||||||||||||||||||
| 343 | 2 | return; | |||||||||||||||||||||||||||||||||||||||
| 344 | } | ||||||||||||||||||||||||||||||||||||||||
| 345 | |||||||||||||||||||||||||||||||||||||||||
| 346 | 0 | ▶ | sub _mark_reset { | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
_mark_reset: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||
| 347 | 0 | my ($self, $code) = @_; | |||||||||||||||||||||||||||||||||||||||
| 348 | |||||||||||||||||||||||||||||||||||||||||
| 349 | 0 | ▶ | return if defined $self->{reset_code}; | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 350 | |||||||||||||||||||||||||||||||||||||||||
| 351 | 0 | $self->{reset_code} = 0 + $code; | |||||||||||||||||||||||||||||||||||||||
| 352 | 0 | $self->{initial} = undef; | |||||||||||||||||||||||||||||||||||||||
| 353 | 0 | $self->{flow_blocked} = 0; | |||||||||||||||||||||||||||||||||||||||
| 354 | |||||||||||||||||||||||||||||||||||||||||
| 355 | 0 | my $callback = $self->{on_reset}; | |||||||||||||||||||||||||||||||||||||||
| 356 | $callback->($self, $self->{reset_code}) | ||||||||||||||||||||||||||||||||||||||||
| 357 | 0 | ▶ | if defined $callback; | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 358 | |||||||||||||||||||||||||||||||||||||||||
| 359 | 0 | return; | |||||||||||||||||||||||||||||||||||||||
| 360 | } | ||||||||||||||||||||||||||||||||||||||||
| 361 | |||||||||||||||||||||||||||||||||||||||||
| 362 | 0 | ▶ | sub _mark_stop { | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
_mark_stop: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||
| 363 | 0 | my ($self, $code) = @_; | |||||||||||||||||||||||||||||||||||||||
| 364 | |||||||||||||||||||||||||||||||||||||||||
| 365 | 0 | ▶ | return if defined $self->{stop_code}; | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 366 | |||||||||||||||||||||||||||||||||||||||||
| 367 | 0 | $self->{stop_code} = 0 + $code; | |||||||||||||||||||||||||||||||||||||||
| 368 | 0 | $self->{flow_blocked} = 0; | |||||||||||||||||||||||||||||||||||||||
| 369 | |||||||||||||||||||||||||||||||||||||||||
| 370 | 0 | my $callback = $self->{on_stop}; | |||||||||||||||||||||||||||||||||||||||
| 371 | $callback->($self, $self->{stop_code}) | ||||||||||||||||||||||||||||||||||||||||
| 372 | 0 | ▶ | if defined $callback; | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 373 | |||||||||||||||||||||||||||||||||||||||||
| 374 | 0 | return; | |||||||||||||||||||||||||||||||||||||||
| 375 | } | ||||||||||||||||||||||||||||||||||||||||
| 376 | |||||||||||||||||||||||||||||||||||||||||
| 377 | 2 | 1; | |||||||||||||||||||||||||||||||||||||||
| 378 | |||||||||||||||||||||||||||||||||||||||||
| 379 | __END__ | ||||||||||||||||||||||||||||||||||||||||