blib/lib/Unblock/HTTP3/Connection.pm

filter: Statementstmt 87.0% 1733 / 1990 Branchbran 65.5% 989 / 1510 Conditioncond 51.9% 363 / 699 MC/DCmcdc 22.6% 89 / 393 Subroutinesub 85.9% 135 / 157 Podpod 0.0% 0 / 42 totaltotal 69.0% 3309 / 4791 CC 1025 SCAR 42.1
CC
1025
Cov
73%
_new
359.7
_drain_events
203.7
request
173.7
CRAP 67.4
↑ Summary blib/lib/Unblock/HTTP3/Capsule/Stream.pm »
1 package Unblock::HTTP3::Connection;
2  
3 18 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 18 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 18 ▶use Carp qw(croak);
Subroutine BEGIN: called CC=1 SCAR=0.0
6 18 ▶use Uniform::HTTP::Request 0.06 ();
Subroutine BEGIN: called CC=1 SCAR=0.0
7 18 ▶use Uniform::HTTP::Response 0.06 ();
Subroutine BEGIN: called CC=1 SCAR=0.0
8 18 ▶use Scalar::Util qw(blessed weaken);
Subroutine BEGIN: called CC=1 SCAR=0.0
9 18 ▶use Time::HiRes ();
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 18 ▶use Unblock::HTTP3 ();
Subroutine BEGIN: called CC=1 SCAR=0.0
12 18 ▶use Unblock::HTTP3::_Native ();
Subroutine BEGIN: called CC=1 SCAR=0.0
13 18 ▶use Unblock::HTTP3::Transaction ();
Subroutine BEGIN: called CC=1 SCAR=0.0
14 18 ▶use Net::QUIC::Connection ();
Subroutine BEGIN: called CC=1 SCAR=0.0
15  
16 18 our $VERSION = '0.12';
17  
18 18 my $H3_DATAGRAM_ERROR = 0x33;
19 18 my $H3_CLOSED_CRITICAL_STREAM = 0x0104;
20 18 my $H3_EXCESSIVE_LOAD = 0x0107;
21 18 my $H3_ID_ERROR = 0x0108;
22 18 my $H3_SETTINGS_ERROR = 0x0109;
23 18 my $QPACK_DECODER_STREAM_ERROR = 0x0202;
24 18 my $H3_REQUEST_CANCELLED = 0x010c;
25 18 my $H3_MESSAGE_ERROR = 0x010e;
26 18 my $HTTP3_MAX_VARINT = '4611686018427387903';
27 18 my $HTTP3_MAX_QUARTER_STREAM_ID = '1152921504606846975';
28 18 my $SETTINGS_STATE_MAGIC = "UH3S";
29 18 my $SETTINGS_STATE_VERSION = 1;
30  
31 18 my %SETTING_DEFAULT = (
32 1 => '0',
33 6 => $HTTP3_MAX_VARINT,
34 7 => '0',
35 8 => '0',
36 51 => '0',
37 );
38  
39 18 my %CORE_SETTING_ID = map { $_ => 1 } qw(1 6 7 8 51);
40 18 my %RESERVED_SETTING_ID = map { $_ => 1 } qw(0 2 3 4 5);
41 18 my %CORE_STREAM_TYPE = map { $_ => 1 } qw(0 1 2 3);
42 18 my %CONNECTION_SPECIFIC_FIELD = map { $_ => 1 } qw(
43 connection
44 keep-alive
45 proxy-connection
46 transfer-encoding
47 upgrade
48 );
49  
50 44 ▶sub _decimal_mod {
Subroutine _decimal_mod: called CC=2 SCAR=6.9
51 44 my ($value, $divisor) = @_;
52  
53 44 my $remainder = 0;
54  
55 44 for my $digit (split //, "$value") {
56 108 $remainder = ($remainder * 10 + ord($digit) - 48) % $divisor;
57 }
58  
59 44 return $remainder;
60 }
61  
62 35 ▶sub _is_grease_setting_id {
Subroutine _is_grease_setting_id: called CC=5 SCAR=16.7
63 35 my ($id) = @_;
64  
65 35 ▶ return 0 if length($id) < 2;
Branch: 1 branch
BranchTrueFalseTotal
if length $id < 2 0 35 35
66 35 ▶ return 0 if length($id) == 2 && $id lt '33';
Branch: 1 branch
BranchTrueFalseTotal
if length $id == 2 and $id lt 33 0 35 35
Condition66%2/3
length $id == 2 and $id lt 33
!ll&&!rl&&r
10250
MC/DC0%0/2
length $id == 2 and $id lt 33
length $id == 2 $id lt 33
Truth table66%2/3
A and B
A= length $id == 2B= $id lt 33
ABresult
0X0
100
111
67  
68 35 ▶ return _decimal_mod($id, 31) == 2 ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
_decimal_mod($id, 31) == 2 ? : 4 31 35
69 }
70  
71 22 ▶sub _assert_extension_setting_id {
Subroutine _assert_extension_setting_id: called CC=4 SCAR=13.9
72 22 my ($id) = @_;
73  
74 croak "HTTP/3 setting $id is reserved for dedicated Unblock::HTTP3 support"
75 22 ▶ if $CORE_SETTING_ID{$id};
Branch: 1 branch
BranchTrueFalseTotal
if $CORE_SETTING_ID{$id} 3 19 22
76 croak "HTTP/3 setting $id is reserved"
77 19 ▶ if $RESERVED_SETTING_ID{$id};
Branch: 1 branch
BranchTrueFalseTotal
if $RESERVED_SETTING_ID{$id} 5 14 19
78 14 ▶ croak "HTTP/3 setting $id is reserved for greasing"
Branch: 1 branch
BranchTrueFalseTotal
if _is_grease_setting_id($id) 3 11 14
79 if _is_grease_setting_id($id);
80  
81 11 return;
82 }
83  
84 112 ▶sub _is_peer_extension_setting_id {
Subroutine _is_peer_extension_setting_id: called CC=4 SCAR=13.9
85 112 my ($id) = @_;
86  
87 112 ▶ return 0 if $CORE_SETTING_ID{$id};
Branch: 1 branch
BranchTrueFalseTotal
if $CORE_SETTING_ID{$id} 91 21 112
88 21 ▶ return 0 if $RESERVED_SETTING_ID{$id};
Branch: 1 branch
BranchTrueFalseTotal
if $RESERVED_SETTING_ID{$id} 0 21 21
89 21 ▶ return 0 if _is_grease_setting_id($id);
Branch: 1 branch
BranchTrueFalseTotal
if _is_grease_setting_id($id) 1 20 21
90  
91 20 return 1;
92 }
93  
94 9 ▶sub _is_grease_stream_type {
Subroutine _is_grease_stream_type: called CC=5 SCAR=17.5
95 9 my ($type) = @_;
96  
97 9 ▶ return 0 if length($type) < 2;
Branch: 1 branch
BranchTrueFalseTotal
if length $type < 2 0 9 9
98 9 ▶ return 0 if length($type) == 2 && $type lt '33';
Branch: 1 branch
BranchTrueFalseTotal
if length $type == 2 and $type lt 33 0 9 9
Condition33%1/3
length $type == 2 and $type lt 33
!ll&&!rl&&r
090
MC/DC0%0/2
length $type == 2 and $type lt 33
length $type == 2 $type lt 33
Truth table33%1/3
A and B
A= length $type == 2B= $type lt 33
ABresult
0X0
100
111
99  
100 9 ▶ return _decimal_mod($type, 31) == 2 ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
_decimal_mod($type, 31) == 2 ? : 1 8 9
101 }
102  
103 7 ▶sub _assert_extension_stream_type {
Subroutine _assert_extension_stream_type: called CC=3 SCAR=11.0
104 7 my ($type) = @_;
105  
106 croak "HTTP/3 stream type $type is managed by Unblock::HTTP3"
107 7 ▶ if $CORE_STREAM_TYPE{$type};
Branch: 1 branch
BranchTrueFalseTotal
if $CORE_STREAM_TYPE{$type} 1 6 7
108 6 ▶ croak "HTTP/3 stream type $type is reserved for greasing"
Branch: 1 branch
BranchTrueFalseTotal
if _is_grease_stream_type($type) 1 5 6
109 if _is_grease_stream_type($type);
110  
111 5 return;
112 }
113  
114 27 ▶sub _normalize_extension_stream_handlers {
Subroutine _normalize_extension_stream_handlers: called CC=6 SCAR=18.1
115 27 my ($handlers) = @_;
116  
117 27 ▶ return {} unless defined $handlers;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $handlers 25 2 27
118  
119 2 ▶ croak 'extension_stream_handlers must be a hash reference'
Branch: 1 branch
BranchTrueFalseTotal
unless ref $handlers eq "HASH" 0 2 2
120 unless ref($handlers) eq 'HASH';
121  
122 2 my %normalized;
123  
124 2 for my $raw_type (keys %$handlers) {
125 2 my $type = _normalize_http3_varint(
126 $raw_type,
127 'extension stream type',
128 );
129  
130 2 _assert_extension_stream_type($type);
131  
132 2 my $callback = $handlers->{$raw_type};
133  
134 2 ▶ croak "extension stream handler for type $type must be a code reference"
Branch: 1 branch
BranchTrueFalseTotal
unless ref $callback eq "CODE" 0 2 2
135 unless ref($callback) eq 'CODE';
136 croak "duplicate extension stream type $type"
137 2 ▶ if exists $normalized{$type};
Branch: 1 branch
BranchTrueFalseTotal
if exists $normalized{$type} 0 2 2
138  
139 2 $normalized{$type} = $callback;
140 }
141  
142 2 return \%normalized;
143 }
144  
145 163 ▶sub _exceeds_http3_varint {
Subroutine _exceeds_http3_varint: called CC=5 SCAR=16.2
146 163 my ($value) = @_;
147  
148 163 my $text = "$value";
149 163 $text =~ s/\A0+//;
150 163 ▶ $text = '0' if $text eq '';
Branch: 1 branch
BranchTrueFalseTotal
if $text eq "" 4 159 163
151  
152 163 ▶ return 1 if length($text) > length($HTTP3_MAX_VARINT);
Branch: 1 branch
BranchTrueFalseTotal
if length $text > length $HTTP3_MAX_VARINT 0 163 163
153 163 ▶ return 0 if length($text) < length($HTTP3_MAX_VARINT);
Branch: 1 branch
BranchTrueFalseTotal
if length $text < length $HTTP3_MAX_VARINT 161 2 163
154  
155 2 ▶ return $text gt $HTTP3_MAX_VARINT ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$text gt $HTTP3_MAX_VARINT ? : 2 0 2
156 }
157  
158 89 ▶sub _normalize_http3_varint {
Subroutine _normalize_http3_varint: called CC=6 SCAR=19.6
159 89 my ($value, $name) = @_;
160  
161 89 ▶ $name ||= 'HTTP/3 varint';
Condition50%1/2
$name ||= "HTTP/3 varint"
l!l
890
MC/DC0%0/1
$name ||= "HTTP/3 varint"
$name
Truth table50%1/2
A
A= $name
Aresult
11
00
162  
163 89 ▶ croak "$name must be a non-negative integer"
Branch: 1 branch
BranchTrueFalseTotal
if not defined $value or ref $value or not "$value" =~ /\A[0-9]+\z/ 0 89 89
Condition33%2/6
not defined $value or ref $value or not "$value" =~ /\A[0-9]+\z/
l!l&&r!l&&!r
0089
not defined $value or ref $value
l!l&&r!l&&!r
0089
MC/DC0%0/3
not defined $value or ref $value or not "$value" =~ /\A[0-9]+\z/
not defined $value ref $value not "$value" =~ /\A[0-9]+\z/
Truth table25%1/4
not(A) or B or not(C)
A= not defined $valueB= ref $valueC= not "$value" =~ /\A[0-9]+\z/
ABCresult
1XX1
01X1
0011
0000
164 if !defined($value)
165 || ref($value)
166 || "$value" !~ /\A[0-9]+\z/;
167  
168 89 my $text = "$value";
169 89 $text =~ s/\A0+(?=[0-9])//;
170  
171 89 ▶ croak "$name exceeds the HTTP/3 varint maximum"
Branch: 1 branch
BranchTrueFalseTotal
if _exceeds_http3_varint($text) 1 88 89
172 if _exceeds_http3_varint($text);
173  
174 88 return $text;
175 }
176  
177 138 ▶sub _encode_http3_varint {
Subroutine _encode_http3_varint: called CC=4 SCAR=13.9
178 138 my ($value) = @_;
179 138 $value = 0 + $value;
180  
181 138 ▶ return pack('C', $value)
Branch: 1 branch
BranchTrueFalseTotal
if $value <= 63 97 41 138
182 if $value <= 63;
183 41 ▶ return pack('n', $value | 0x4000)
Branch: 1 branch
BranchTrueFalseTotal
if $value <= 16383 32 9 41
184 if $value <= 16_383;
185 9 ▶ return pack('N', $value | 0x80000000)
Branch: 1 branch
BranchTrueFalseTotal
if $value <= 1073741823 7 2 9
186 if $value <= 1_073_741_823;
187  
188 2 my $high = (($value >> 32) & 0x3fffffff) | 0xc0000000;
189 2 my $low = $value & 0xffffffff;
190  
191 2 return pack('NN', $high, $low);
192 }
193  
194 518 ▶sub _decode_http3_varint {
Subroutine _decode_http3_varint: called CC=7 SCAR=19.5
195 518 my ($bytes, $offset) = @_;
196 518 ▶ $offset ||= 0;
Condition100%2/2
$offset ||= 0
l!l
166352
MC/DC100%1/1
$offset ||= 0
$offset
Truth table100%2/2
A
A= $offset
Aresult
11
00
197  
198 518 ▶ return if $offset >= length($bytes);
Branch: 1 branch
BranchTrueFalseTotal
if $offset >= length $bytes 57 461 518
199  
200 461 my $first = ord(substr($bytes, $offset, 1));
201 461 my $length = (1, 2, 4, 8)[ $first >> 6 ];
202  
203 461 ▶ return if length($bytes) - $offset < $length;
Branch: 1 branch
BranchTrueFalseTotal
if length($bytes) - $offset < $length 8 453 461
204  
205 453 my $value;
206  
207 453 ▶ if ($length == 1) {
Branch: 3 branches
BranchTrueFalseTotal
if ($length == 1) { } 340 113 453
elsif ($length == 2) { } 82 31 113
elsif ($length == 4) { } 29 2 31
208 340 $value = $first & 0x3f;
209 } elsif ($length == 2) {
210 82 $value = unpack('n', substr($bytes, $offset, 2)) & 0x3fff;
211 } elsif ($length == 4) {
212 29 $value = unpack('N', substr($bytes, $offset, 4)) & 0x3fffffff;
213 } else {
214 2 my ($high, $low) = unpack('NN', substr($bytes, $offset, 8));
215 2 $high &= 0x3fffffff;
216 2 $value = ($high << 32) | $low;
217 }
218  
219 453 return ("$value", $length);
220 }
221  
222 4 ▶sub _encode_settings_state {
Subroutine _encode_settings_state: called CC=4 SCAR=13.9
223 4 my ($settings) = @_;
224  
225 4 ▶ croak 'HTTP/3 settings state requires a hash reference'
Branch: 1 branch
BranchTrueFalseTotal
unless ref $settings eq "HASH" 0 4 4
226 unless ref($settings) eq 'HASH';
227  
228 my @ids = sort {
229 4 ▶ length($a) <=> length($b)
Condition66%2/3
length $a <=> length $b || $a cmp $b
l!l&&r!l&&!r
17210
MC/DC0%0/2
length $a <=> length $b || $a cmp $b
length $a <=> length $b $a cmp $b
Truth table66%2/3
A || B
A= length $a <=> length $bB= $a cmp $b
ABresult
1X1
011
000
230 || $a cmp $b
231 } keys %$settings;
232  
233 4 my $out = $SETTINGS_STATE_MAGIC
234 . pack('C', $SETTINGS_STATE_VERSION)
235 . _encode_http3_varint(scalar @ids);
236  
237 4 for my $id (@ids) {
238 23 my $normalized_id = _normalize_http3_varint(
239 $id,
240 'settings state identifier',
241 );
242 my $value = _normalize_http3_varint(
243 23 $settings->{$id},
244 "settings state value for $normalized_id",
245 );
246  
247 23 $out .= _encode_http3_varint($normalized_id);
248 23 $out .= _encode_http3_varint($value);
249 }
250  
251 4 return $out;
252 }
253  
254 7 ▶sub _decode_settings_state {
Subroutine _decode_settings_state: called CC=13 SCAR=27.3
255 7 my ($state, $name) = @_;
256 7 ▶ $name ||= 'HTTP/3 settings state';
Condition50%1/2
$name ||= "HTTP/3 settings state"
l!l
70
MC/DC0%0/1
$name ||= "HTTP/3 settings state"
$name
Truth table50%1/2
A
A= $name
Aresult
11
00
257  
258 7 ▶ croak "$name must be an opaque byte string returned by Unblock::HTTP3"
Branch: 1 branch
BranchTrueFalseTotal
if not defined $state or ref $state 0 7 7
Condition33%1/3
not defined $state or ref $state
l!l&&r!l&&!r
007
MC/DC0%0/2
not defined $state or ref $state
not defined $state ref $state
Truth table33%1/3
not(A) or B
A= not defined $stateB= ref $state
ABresult
1X1
011
000
259 if !defined($state) || ref($state);
260  
261 7 my $header_length = length($SETTINGS_STATE_MAGIC) + 1;
262 7 ▶ croak "invalid $name"
Branch: 1 branch
BranchTrueFalseTotal
if length $state < $header_length or substr($state, 0, length $SETTINGS_STATE_MAGIC) ne $SETTINGS_STATE_MAGIC or ord substr($state, length $SETTINGS_STATE_MAGIC, 1) != $SETTINGS_STATE_VERSION 1 6 7
Condition66%4/6
length $state < $header_length or substr($state, 0, length $SETTINGS_STATE_MAGIC) ne $SETTINGS_STATE_MAGIC or ord substr($state, length $SETTINGS_STATE_MAGIC, 1) != $SETTINGS_STATE_VERSION
l!l&&r!l&&!r
106
length $state < $header_length or substr($state, 0, length $SETTINGS_STATE_MAGIC) ne $SETTINGS_STATE_MAGIC
l!l&&r!l&&!r
016
MC/DC33%1/3
length $state < $header_length or substr($state, 0, length $SETTINGS_STATE_MAGIC) ne $SETTINGS_STATE_MAGIC or ord substr($state, length $SETTINGS_STATE_MAGIC, 1) != $SETTINGS_STATE_VERSION
length $state < $header_length substr($state, 0, length $SETTINGS_STATE_MAGIC) ne $SETTINGS_STATE_MAGIC ord substr($state, length $SETTINGS_STATE_MAGIC, 1) != $SETTINGS_STATE_VERSION
Truth table50%2/4
A or B or C
A= length $state < $header_lengthB= substr($state, 0, length $SETTINGS_STATE_MAGIC) ne $SETTINGS_STATE_MAGICC= ord substr($state, length $SETTINGS_STATE_MAGIC, 1) != $SETTINGS_STATE_VERSION
ABCresult
1XX1
01X1
0011
0000
263 if length($state) < $header_length
264 || substr($state, 0, length($SETTINGS_STATE_MAGIC))
265 ne $SETTINGS_STATE_MAGIC
266 || ord(substr($state, length($SETTINGS_STATE_MAGIC), 1))
267 != $SETTINGS_STATE_VERSION;
268  
269 6 my $offset = $header_length;
270 6 my ($count, $count_length) = _decode_http3_varint($state, $offset);
271 6 ▶ croak "invalid $name" unless defined $count;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $count 0 6 6
272 6 $offset += $count_length;
273  
274 6 my %settings;
275  
276 6 for (1 .. 0 + $count) {
277 35 my ($id, $id_length) = _decode_http3_varint($state, $offset);
278 35 ▶ croak "invalid $name" unless defined $id;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $id 0 35 35
279 35 $offset += $id_length;
280  
281 35 my ($value, $value_length) = _decode_http3_varint($state, $offset);
282 35 ▶ croak "invalid $name" unless defined $value;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $value 0 35 35
283 35 $offset += $value_length;
284  
285 croak "invalid $name: duplicate setting $id"
286 35 ▶ if exists $settings{$id};
Branch: 1 branch
BranchTrueFalseTotal
if exists $settings{$id} 0 35 35
287  
288 35 $settings{$id} = $value;
289 }
290  
291 6 ▶ croak "invalid $name: trailing bytes"
Branch: 1 branch
BranchTrueFalseTotal
if $offset != length $state 0 6 6
292 if $offset != length($state);
293  
294 6 return \%settings;
295 }
296  
297 77 ▶sub _effective_setting {
Subroutine _effective_setting: called CC=3 SCAR=16.5
298 77 my ($settings, $id) = @_;
299  
300 return $settings->{$id}
301 77 ▶ if exists $settings->{$id};
Branch: 1 branch
BranchTrueFalseTotal
if exists $settings->{$id} 77 0 77
302  
303 return $SETTING_DEFAULT{$id}
304 0 ▶ if exists $SETTING_DEFAULT{$id};
Branch: 1 branch
BranchTrueFalseTotal
if exists $SETTING_DEFAULT{$id} 0 0 0
305  
306 0 return;
307 }
308  
309 9 ▶sub _settings_compatibility_error {
Subroutine _settings_compatibility_error: called CC=18 SCAR=31.4
310 9 my ($remembered, $current) = @_;
311  
312 9 my $old_qpack_capacity = _effective_setting($remembered, 1);
313 9 my $new_qpack_capacity = _effective_setting($current, 1);
314  
315 9 ▶ if ($old_qpack_capacity ne '0') {
Branch: 1 branch
BranchTrueFalseTotal
if ($old_qpack_capacity ne 0) 9 0 9
316 9 ▶ if (
Branch: 1 branch
BranchTrueFalseTotal
if (not exists $current->{1} or $new_qpack_capacity ne $old_qpack_capacity) 2 7 9
Condition66%2/3
not exists $current->{1} or $new_qpack_capacity ne $old_qpack_capacity
l!l&&r!l&&!r
027
MC/DC50%1/2
not exists $current->{1} or $new_qpack_capacity ne $old_qpack_capacity
not exists $current->{1} $new_qpack_capacity ne $old_qpack_capacity
Truth table66%2/3
not(A) or B
A= not exists $current->{1}B= $new_qpack_capacity ne $old_qpack_capacity
ABresult
1X1
011
000
317 !exists($current->{1})
318 || $new_qpack_capacity ne $old_qpack_capacity
319 ) {
320 2 my $message =
321 "SETTINGS_QPACK_MAX_TABLE_CAPACITY changed from "
322 . "$old_qpack_capacity to $new_qpack_capacity";
323  
324 return wantarray
325 2 ▶ ? ($QPACK_DECODER_STREAM_ERROR, $message)
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 1 1 2
326 : $message;
327 }
328 }
329  
330 7 for my $id (qw(6 7 8 51)) {
331 25 my $old = _effective_setting($remembered, $id);
332 25 my $new = _effective_setting($current, $id);
333  
334 25 ▶ if (_decimal_less_than($new, $old)) {
Branch: 1 branch
BranchTrueFalseTotal
if (_decimal_less_than($new, $old)) 2 23 25
335 2 ▶ my $message = $id == 6
Branch: 1 branch
BranchTrueFalseTotal
$id == 6 ? : 1 1 2
336 ? "SETTINGS_MAX_FIELD_SECTION_SIZE decreased from $old to $new"
337 : "HTTP/3 setting $id decreased from $old to $new";
338  
339 return wantarray
340 2 ▶ ? ($H3_SETTINGS_ERROR, $message)
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 0 2 2
341 : $message;
342 }
343  
344 23 ▶ if (
Branch: 1 branch
BranchTrueFalseTotal
if (exists $remembered->{$id} and $remembered->{$id} ne $SETTING_DEFAULT{$id} and not exists $current->{$id}) 0 23 23
Condition33%2/6
exists $remembered->{$id} and $remembered->{$id} ne $SETTING_DEFAULT{$id} and not exists $current->{$id}
!ll&&!rl&&r
0230
exists $remembered->{$id} and $remembered->{$id} ne $SETTING_DEFAULT{$id}
!ll&&!rl&&r
0023
MC/DC0%0/3
exists $remembered->{$id} and $remembered->{$id} ne $SETTING_DEFAULT{$id} and not exists $current->{$id}
exists $remembered->{$id} $remembered->{$id} ne $SETTING_DEFAULT{$id} not exists $current->{$id}
Truth table25%1/4
A and B and not(C)
A= exists $remembered->{$id}B= $remembered->{$id} ne $SETTING_DEFAULT{$id}C= not exists $current->{$id}
ABCresult
0XX0
10X0
1100
1111
345 exists($remembered->{$id})
346 && $remembered->{$id} ne $SETTING_DEFAULT{$id}
347 && !exists($current->{$id})
348 ) {
349 0 my $message =
350 "HTTP/3 setting $id was previously non-default but is now omitted";
351  
352 return wantarray
353 0 ▶ ? ($H3_SETTINGS_ERROR, $message)
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 0 0 0
354 : $message;
355 }
356 }
357  
358 5 for my $id (
359 grep {
360 30 _is_peer_extension_setting_id($_)
361 } keys %$remembered
362 ) {
363 5 ▶ if (
Branch: 1 branch
BranchTrueFalseTotal
if (not exists $current->{$id} or $remembered->{$id} ne $current->{$id}) 1 4 5
Condition66%2/3
not exists $current->{$id} or $remembered->{$id} ne $current->{$id}
l!l&&r!l&&!r
014
MC/DC50%1/2
not exists $current->{$id} or $remembered->{$id} ne $current->{$id}
not exists $current->{$id} $remembered->{$id} ne $current->{$id}
Truth table66%2/3
not(A) or B
A= not exists $current->{$id}B= $remembered->{$id} ne $current->{$id}
ABresult
1X1
011
000
364 !exists($current->{$id})
365 || $remembered->{$id} ne $current->{$id}
366 ) {
367 1 my $message = "extension setting $id changed across 0-RTT";
368  
369 return wantarray
370 1 ▶ ? ($H3_SETTINGS_ERROR, $message)
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 0 1 1
371 : $message;
372 }
373 }
374  
375 4 ▶ return wantarray ? () : undef;
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 1 3 4
376 }
377  
378 39 ▶sub _normalize_extension_settings {
Subroutine _normalize_extension_settings: called CC=5 SCAR=16.2
379 39 my ($settings) = @_;
380  
381 39 ▶ return {} unless defined $settings;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $settings 18 21 39
382  
383 21 ▶ croak 'extension_settings must be a hash reference'
Branch: 1 branch
BranchTrueFalseTotal
unless ref $settings eq "HASH" 0 21 21
384 unless ref($settings) eq 'HASH';
385  
386 21 my %normalized;
387  
388 21 for my $raw_id (keys %$settings) {
389 22 my $id = _normalize_http3_varint(
390 $raw_id,
391 'extension setting identifier',
392 );
393  
394 22 _assert_extension_setting_id($id);
395  
396 my $value = _normalize_http3_varint(
397 11 $settings->{$raw_id},
398 "extension setting $id value",
399 );
400  
401 croak "duplicate extension setting identifier $id"
402 10 ▶ if exists $normalized{$id};
Branch: 1 branch
BranchTrueFalseTotal
if exists $normalized{$id} 0 10 10
403  
404 10 $normalized{$id} = $value;
405 }
406  
407 9 return \%normalized;
408 }
409  
410 10 ▶sub _rewrite_control_settings {
Subroutine _rewrite_control_settings: called CC=15 SCAR=29.0
411 10 my ($bytes, $extension_settings) = @_;
412  
413 10 my ($stream_type, $stream_type_length) =
414 _decode_http3_varint($bytes, 0);
415  
416 10 ▶ croak 'libnghttp3 split the initial HTTP/3 control stream type'
Branch: 1 branch
BranchTrueFalseTotal
unless defined $stream_type 0 10 10
417 unless defined $stream_type;
418 10 ▶ croak 'libnghttp3 produced an unexpected initial control stream type'
Branch: 1 branch
BranchTrueFalseTotal
unless $stream_type eq 0 0 10 10
419 unless $stream_type eq '0';
420  
421 10 my $frame_type_offset = $stream_type_length;
422 10 my ($frame_type, $frame_type_length) =
423 _decode_http3_varint($bytes, $frame_type_offset);
424  
425 10 ▶ croak 'libnghttp3 split the initial HTTP/3 SETTINGS frame type'
Branch: 1 branch
BranchTrueFalseTotal
unless defined $frame_type 0 10 10
426 unless defined $frame_type;
427 10 ▶ croak 'libnghttp3 did not emit SETTINGS first on the control stream'
Branch: 1 branch
BranchTrueFalseTotal
unless $frame_type eq 4 0 10 10
428 unless $frame_type eq '4';
429  
430 10 my $frame_length_offset = $frame_type_offset + $frame_type_length;
431 10 my ($frame_length, $frame_length_length) =
432 _decode_http3_varint($bytes, $frame_length_offset);
433  
434 10 ▶ croak 'libnghttp3 split the initial HTTP/3 SETTINGS frame length'
Branch: 1 branch
BranchTrueFalseTotal
unless defined $frame_length 0 10 10
435 unless defined $frame_length;
436  
437 10 my $payload_offset = $frame_length_offset + $frame_length_length;
438 10 my $payload_length = 0 + $frame_length;
439  
440 10 ▶ croak 'libnghttp3 split the initial HTTP/3 SETTINGS frame payload'
Branch: 1 branch
BranchTrueFalseTotal
if length($bytes) - $payload_offset < $payload_length 0 10 10
441 if length($bytes) - $payload_offset < $payload_length;
442  
443 10 my $payload = substr($bytes, $payload_offset, $payload_length);
444 10 my %existing;
445 10 my $offset = 0;
446  
447 10 ▶ while ($offset < length($payload)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($offset < length $payload) 40 10 50
448 40 my ($id, $id_length) = _decode_http3_varint($payload, $offset);
449 40 ▶ croak 'libnghttp3 produced a malformed SETTINGS identifier'
Branch: 1 branch
BranchTrueFalseTotal
unless defined $id 0 40 40
450 unless defined $id;
451 40 $offset += $id_length;
452  
453 40 my ($value, $value_length) =
454 _decode_http3_varint($payload, $offset);
455 40 ▶ croak 'libnghttp3 produced a malformed SETTINGS value'
Branch: 1 branch
BranchTrueFalseTotal
unless defined $value 0 40 40
456 unless defined $value;
457 40 $offset += $value_length;
458  
459 croak "libnghttp3 produced duplicate SETTINGS identifier $id"
460 40 ▶ if exists $existing{$id};
Branch: 1 branch
BranchTrueFalseTotal
if exists $existing{$id} 0 40 40
461  
462 40 $existing{$id} = $value;
463 }
464  
465 10 my $extra = '';
466  
467 10 for my $id (
468 sort {
469 2 ▶ length($a) <=> length($b)
Condition33%1/3
length $a <=> length $b || $a cmp $b
l!l&&r!l&&!r
020
MC/DC0%0/2
length $a <=> length $b || $a cmp $b
length $a <=> length $b $a cmp $b
Truth table33%1/3
A || B
A= length $a <=> length $bB= $a cmp $b
ABresult
1X1
011
000
470 || $a cmp $b
471 } keys %$extension_settings
472 ) {
473 12 my $value = $extension_settings->{$id};
474  
475 12 ▶ if (exists $existing{$id}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $existing{$id}) 0 12 12
476 croak "extension setting $id conflicts with libnghttp3"
477 0 ▶ if $existing{$id} ne $value;
Branch: 1 branch
BranchTrueFalseTotal
if $existing{$id} ne $value 0 0 0
478 0 next;
479 }
480  
481 12 $extra .= _encode_http3_varint($id);
482 12 $extra .= _encode_http3_varint($value);
483 }
484  
485 10 my $new_payload = $payload . $extra;
486 10 my $payload_end = $payload_offset + $payload_length;
487  
488 10 my $rewritten =
489 substr($bytes, 0, $frame_length_offset)
490 . _encode_http3_varint(length($new_payload))
491 . $new_payload
492 . substr($bytes, $payload_end);
493  
494 10 return ($rewritten, length($bytes), length($rewritten) - length($bytes));
495 }
496  
497 254 ▶sub _inspect_peer_settings_bytes {
Subroutine _inspect_peer_settings_bytes: called CC=25 SCAR=32.6
498 254 my ($self, $id, $bytes) = @_;
499  
500 254 ▶ return unless ($id & 0x2) == 0x2;
Branch: 1 branch
BranchTrueFalseTotal
unless ($id & 2) == 2 133 121 254
501  
502 121 my $state = $self->{peer_settings_parser}{$id};
503  
504 121 ▶ if (!defined $state) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $state) 41 80 121
505 41 $state = {
506 stage => 'stream_type',
507 buffer => '',
508 remaining => undef,
509 settings => {},
510 };
511 41 $self->{peer_settings_parser}{$id} = $state;
512 }
513  
514 return if $state->{stage} eq 'ignore'
515 121 ▶ || $state->{stage} eq 'done';
Branch: 1 branch
BranchTrueFalseTotal
if $state->{"stage"} eq "ignore" or $state->{"stage"} eq "done" 56 65 121
Condition100%3/3
$state->{"stage"} eq "ignore" or $state->{"stage"} eq "done"
l!l&&r!l&&!r
55165
MC/DC100%2/2
$state->{"stage"} eq "ignore" or $state->{"stage"} eq "done"
$state->{"stage"} eq "ignore" $state->{"stage"} eq "done"
Truth table100%3/3
A or B
A= $state->{"stage"} eq "ignore"B= $state->{"stage"} eq "done"
ABresult
1X1
011
000
516  
517 65 $state->{buffer} .= $bytes;
518  
519 65 while (1) {
520 249 ▶ if ($state->{stage} eq 'stream_type') {
Branch: 1 branch
BranchTrueFalseTotal
if ($state->{"stage"} eq "stream_type") 41 208 249
521 my ($value, $length) =
522 41 _decode_http3_varint($state->{buffer}, 0);
523 41 ▶ return unless defined $value;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $value 0 41 41
524  
525 41 substr($state->{buffer}, 0, $length, '');
526  
527 41 ▶ if ($value ne '0') {
Branch: 1 branch
BranchTrueFalseTotal
if ($value ne 0) 24 17 41
528 24 $state->{stage} = 'ignore';
529 24 $state->{buffer} = '';
530 24 return;
531 }
532  
533 17 $state->{stage} = 'frame_type';
534 17 next;
535 }
536  
537 208 ▶ if ($state->{stage} eq 'frame_type') {
Branch: 1 branch
BranchTrueFalseTotal
if ($state->{"stage"} eq "frame_type") 19 189 208
538 my ($value, $length) =
539 19 _decode_http3_varint($state->{buffer}, 0);
540 19 ▶ return unless defined $value;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $value 2 17 19
541  
542 17 substr($state->{buffer}, 0, $length, '');
543  
544 17 ▶ if ($value ne '4') {
Branch: 1 branch
BranchTrueFalseTotal
if ($value ne 4) 0 17 17
545 0 $state->{stage} = 'ignore';
546 0 $state->{buffer} = '';
547 0 return;
548 }
549  
550 17 $state->{stage} = 'frame_length';
551 17 next;
552 }
553  
554 189 ▶ if ($state->{stage} eq 'frame_length') {
Branch: 1 branch
BranchTrueFalseTotal
if ($state->{"stage"} eq "frame_length") 19 170 189
555 my ($value, $length) =
556 19 _decode_http3_varint($state->{buffer}, 0);
557 19 ▶ return unless defined $value;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $value 2 17 19
558  
559 17 substr($state->{buffer}, 0, $length, '');
560 17 $state->{remaining} = 0 + $value;
561 17 $state->{stage} = 'setting_id';
562 17 next;
563 }
564  
565 170 ▶ if ($state->{stage} eq 'setting_id') {
Branch: 1 branch
BranchTrueFalseTotal
if ($state->{"stage"} eq "setting_id") 91 79 170
566 91 ▶ if ($state->{remaining} == 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($state->{"remaining"} == 0) 14 77 91
567 my %extension = map {
568 12 $_ => $state->{settings}{$_}
569 } grep {
570 64 _is_peer_extension_setting_id($_)
571 14 } keys %{ $state->{settings} };
572  
573 $self->{pending_peer_settings} = {
574 14 %{ $state->{settings} },
575 };
576 14 $self->{pending_peer_extension_settings} = \%extension;
577 14 $state->{stage} = 'done';
578 14 $state->{buffer} = '';
579 14 return;
580 }
581  
582 my ($value, $length) =
583 77 _decode_http3_varint($state->{buffer}, 0);
584 77 ▶ return unless defined $value;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $value 9 68 77
585  
586 68 ▶ if ($length > $state->{remaining}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($length > $state->{"remaining"}) 0 68 68
587 0 $state->{stage} = 'ignore';
588 0 $state->{buffer} = '';
589 0 return;
590 }
591  
592 68 substr($state->{buffer}, 0, $length, '');
593 68 $state->{remaining} -= $length;
594 68 $state->{setting_id} = $value;
595 68 $state->{stage} = 'setting_value';
596 68 next;
597 }
598  
599 79 ▶ if ($state->{stage} eq 'setting_value') {
Branch: 1 branch
BranchTrueFalseTotal
if ($state->{"stage"} eq "setting_value") 79 0 79
600 my ($value, $length) =
601 79 _decode_http3_varint($state->{buffer}, 0);
602 79 ▶ return unless defined $value;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $value 11 68 79
603  
604 68 ▶ if ($length > $state->{remaining}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($length > $state->{"remaining"}) 0 68 68
605 0 $state->{stage} = 'ignore';
606 0 $state->{buffer} = '';
607 0 return;
608 }
609  
610 68 substr($state->{buffer}, 0, $length, '');
611 68 $state->{remaining} -= $length;
612  
613 68 my $setting_id = delete $state->{setting_id};
614  
615 68 ▶ if (exists $state->{settings}{$setting_id}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $state->{"settings"}{$setting_id}) 1 67 68
616 1 $state->{stage} = 'ignore';
617 1 $state->{buffer} = '';
618  
619 1 $self->_fail_connection(
620 $H3_SETTINGS_ERROR,
621 "peer sent duplicate HTTP/3 setting $setting_id",
622 );
623 1 return;
624 }
625  
626 67 ▶ if (
Branch: 1 branch
BranchTrueFalseTotal
if ($setting_id eq 8 || $setting_id eq 51 and $value ne 0 and $value ne 1) 2 65 67
Condition88%8/9
$setting_id eq 8 || $setting_id eq 51 and $value ne 0 and $value ne 1
!ll&&!rl&&r
52132
$setting_id eq 8 || $setting_id eq 51 and $value ne 0
!ll&&!rl&&r
52015
$setting_id eq 8 or $setting_id eq 51
l!l&&r!l&&!r
6952
MC/DC75%3/4
$setting_id eq 8 || $setting_id eq 51 and $value ne 0 and $value ne 1
$setting_id eq 8 $setting_id eq 51 $value ne 0 $value ne 1
Truth table71%5/7
A or B and C and D
A= $setting_id eq 8B= $setting_id eq 51C= $value ne 0D= $value ne 1
ABCDresult
00XX0
1X0X0
010X0
1X100
01100
1X111
01111
627 ($setting_id eq '8' || $setting_id eq '51')
628 && $value ne '0'
629 && $value ne '1'
630 ) {
631 2 $state->{stage} = 'ignore';
632 2 $state->{buffer} = '';
633  
634 2 $self->_fail_connection(
635 $H3_SETTINGS_ERROR,
636 "peer HTTP/3 setting $setting_id must be 0 or 1",
637 );
638 2 return;
639 }
640  
641 65 $state->{settings}{$setting_id} = $value;
642 65 $state->{stage} = 'setting_id';
643 65 next;
644 }
645  
646 0 croak "unknown peer SETTINGS parser state '$state->{stage}'";
647 }
648 }
649  
650 13 ▶sub _accept_peer_extension_settings {
Subroutine _accept_peer_extension_settings: called CC=10 SCAR=23.4
651 13 my ($self) = @_;
652  
653 13 my $all_settings = delete $self->{pending_peer_settings};
654 13 ▶ $all_settings = {} unless defined $all_settings;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $all_settings 1 12 13
655  
656 13 ▶ if (
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->{"remembered_peer_settings"} and $self->{"quic"}->early_data_status eq "accepted") 1 12 13
Condition100%3/3
defined $self->{"remembered_peer_settings"} and $self->{"quic"}->early_data_status eq "accepted"
!ll&&!rl&&r
1111
MC/DC100%2/2
defined $self->{"remembered_peer_settings"} and $self->{"quic"}->early_data_status eq "accepted"
defined $self->{"remembered_peer_settings"} $self->{"quic"}->early_data_status eq "accepted"
Truth table100%3/3
A and B
A= defined $self->{"remembered_peer_settings"}B= $self->{"quic"}->early_data_status eq "accepted"
ABresult
0X0
100
111
657 defined($self->{remembered_peer_settings})
658 && $self->{quic}->early_data_status eq 'accepted'
659 ) {
660 my ($compatibility_code, $compatibility_error) =
661 _settings_compatibility_error(
662 $self->{remembered_peer_settings},
663 1 $all_settings,
664 );
665  
666 1 ▶ if (defined $compatibility_error) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $compatibility_error) 0 1 1
667 0 $self->_fail_connection(
668 $compatibility_code,
669 "peer SETTINGS are incompatible with accepted 0-RTT: "
670 . $compatibility_error,
671 );
672 0 return;
673 }
674 }
675  
676 13 my $settings = delete $self->{pending_peer_extension_settings};
677 13 ▶ $settings = {} unless defined $settings;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $settings 0 13 13
678  
679 13 $self->{peer_settings_wire} = { %$all_settings };
680 13 $self->{peer_extension_settings} = { %$settings };
681 13 $self->{peer_settings_received} = 1;
682 13 $self->{peer_settings_initialized} = 1;
683  
684 13 my $callback = $self->{on_extension_settings};
685 13 ▶ return 1 unless defined $callback;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $callback 10 3 13
686  
687 3 my $ok = eval {
688 3 $callback->($self, { %$settings });
689 2 1;
690 };
691  
692 3 ▶ return 1 if $ok;
Branch: 1 branch
BranchTrueFalseTotal
if $ok 2 1 3
693  
694 1 my $error = $@;
695 1 ▶ $error = 'extension SETTINGS validation failed'
Branch: 1 branch
BranchTrueFalseTotal
unless defined $error and length $error 0 1 1
Condition33%1/3
defined $error and length $error
!ll&&!rl&&r
001
MC/DC0%0/2
defined $error and length $error
defined $error length $error
Truth table33%1/3
A and B
A= defined $errorB= length $error
ABresult
0X0
100
111
696 unless defined($error) && length($error);
697 1 $error =~ s/\s+\z//;
698  
699 1 $self->_fail_connection(
700 $H3_SETTINGS_ERROR,
701 "peer extension SETTINGS rejected: $error",
702 );
703  
704 1 return;
705 }
706  
707 92 ▶sub _ascii_lc {
Subroutine _ascii_lc: called CC=1 SCAR=0.0
708 92 my ($value) = @_;
709 92 my $copy = "$value";
710 92 $copy =~ tr/A-Z/a-z/;
711 92 return $copy;
712 }
713  
714 14 ▶sub _authority_equal {
Subroutine _authority_equal: called CC=2 SCAR=6.9
715 14 my ($left, $right) = @_;
716 14 ▶ return _ascii_lc($left) eq _ascii_lc($right) ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
_ascii_lc($left) eq _ascii_lc($right) ? : 11 3 14
717 }
718  
719 11 ▶sub _connect_authority_error {
Subroutine _connect_authority_error: called CC=8 SCAR=20.9
720 11 my ($authority) = @_;
721  
722 11 ▶ return 'CONNECT authority must not contain userinfo'
Branch: 1 branch
BranchTrueFalseTotal
if $authority =~ /@/ 0 11 11
723 if $authority =~ /@/;
724  
725 11 my $port;
726  
727 11 ▶ if ($authority =~ /\A\[[^\]]+\]:([0-9]+)\z/) {
Branch: 2 branches
BranchTrueFalseTotal
if ($authority =~ /\A\[[^\]]+\]:([0-9]+)\z/) { } 1 10 11
elsif ($authority =~ /\A[^:]+:([0-9]+)\z/) { } 8 2 10
728 1 $port = $1;
729 } elsif ($authority =~ /\A[^:]+:([0-9]+)\z/) {
730 8 $port = $1;
731 } else {
732 2 return 'CONNECT authority must contain a host and explicit port';
733 }
734  
735 9 $port =~ s/\A0+(?=[0-9])//;
736  
737 9 ▶ return 'CONNECT authority port must be between 1 and 65535'
Branch: 1 branch
BranchTrueFalseTotal
if $port eq 0 or length $port > 5 or length $port == 5 and $port gt 65535 2 7 9
Condition77%7/9
$port eq 0 or length $port > 5 or length $port == 5 and $port gt 65535
l!l&&r!l&&!r
117
$port eq 0 or length $port > 5
l!l&&r!l&&!r
108
length $port == 5 and $port gt 65535
!ll&&!rl&&r
701
MC/DC50%2/4
$port eq 0 or length $port > 5 or length $port == 5 and $port gt 65535
$port eq 0 length $port > 5 length $port == 5 $port gt 65535
Truth table60%3/5
A or B or C and D
A= $port eq 0B= length $port > 5C= length $port == 5D= $port gt 65535
ABCDresult
1XXX1
01XX1
00111
000X0
00100
738 if $port eq '0'
739 || length($port) > 5
740 || (length($port) == 5 && $port gt '65535');
741  
742 7 return;
743 }
744  
745 83 ▶sub _request_semantic_error {
Subroutine _request_semantic_error: called CC=29 SCAR=35.5
746 83 my (%args) = @_;
747  
748 83 my $method = $args{method};
749 83 my $scheme = $args{scheme};
750 83 my $authority = $args{authority};
751 83 my $target = $args{target};
752 83 my $protocol = $args{protocol};
753 83 ▶ my $host_values = $args{host_values} || [];
Condition50%1/2
$args{'host_values'} || []
l!l
830
MC/DC0%0/1
$args{'host_values'} || []
$args{'host_values'}
Truth table50%1/2
A
A= $args{'host_values'}
Aresult
11
00
754  
755 83 ▶ return 'multiple Host fields are not allowed'
Branch: 1 branch
BranchTrueFalseTotal
if @$host_values > 1 0 83 83
756 if @$host_values > 1;
757  
758 83 ▶ my $host = @$host_values ? $host_values->[0] : undef;
Branch: 1 branch
BranchTrueFalseTotal
@$host_values ? : 4 79 83
759  
760 83 ▶ if (defined($authority) && defined($host)) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $authority and defined $host) 4 79 83
Condition66%2/3
defined $authority and defined $host
!ll&&!rl&&r
0794
MC/DC50%1/2
defined $authority and defined $host
defined $authority defined $host
Truth table66%2/3
A and B
A= defined $authorityB= defined $host
ABresult
0X0
100
111
761 4 ▶ return 'Host field must match :authority'
Branch: 1 branch
BranchTrueFalseTotal
unless _authority_equal($authority, $host) 3 1 4
762 unless _authority_equal($authority, $host);
763 }
764  
765 80 ▶ if (defined($protocol) && $method ne 'CONNECT') {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $protocol and $method ne "CONNECT") 1 79 80
Condition100%3/3
defined $protocol and $method ne "CONNECT"
!ll&&!rl&&r
62171
MC/DC100%2/2
defined $protocol and $method ne "CONNECT"
defined $protocol $method ne "CONNECT"
Truth table100%3/3
A and B
A= defined $protocolB= $method ne "CONNECT"
ABresult
0X0
100
111
766 1 return ':protocol is only valid with CONNECT';
767 }
768  
769 79 ▶ if ($method eq 'CONNECT') {
Branch: 1 branch
BranchTrueFalseTotal
if ($method eq "CONNECT") 28 51 79
770 28 ▶ if (defined $protocol) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $protocol) { } 17 11 28
771 17 ▶ return 'Extended CONNECT :protocol must be an HTTP token'
Branch: 1 branch
BranchTrueFalseTotal
unless $protocol =~ /\A[!\#\$%&'*+\-.\^_\x60|~0-9A-Za-z]+\z/ 0 17 17
772 unless $protocol =~ /\A[!\#\$%&'*+\-.\^_\x60|~0-9A-Za-z]+\z/;
773 17 ▶ return 'Extended CONNECT requires :scheme'
Branch: 1 branch
BranchTrueFalseTotal
unless defined $scheme 2 15 17
774 unless defined $scheme;
775 15 ▶ return 'Extended CONNECT requires :path'
Branch: 1 branch
BranchTrueFalseTotal
unless defined $target and length $target 2 13 15
Condition66%2/3
defined $target and length $target
!ll&&!rl&&r
2013
MC/DC50%1/2
defined $target and length $target
defined $target length $target
Truth table66%2/3
A and B
A= defined $targetB= length $target
ABresult
0X0
100
111
776 unless defined $target && length $target;
777 } else {
778 11 ▶ return 'CONNECT requires :authority'
Branch: 1 branch
BranchTrueFalseTotal
unless defined $authority 0 11 11
779 unless defined $authority;
780  
781 11 my $error = _connect_authority_error($authority);
782 11 ▶ return $error if defined $error;
Branch: 1 branch
BranchTrueFalseTotal
if defined $error 4 7 11
783  
784 7 ▶ return 'CONNECT target must match :authority'
Branch: 1 branch
BranchTrueFalseTotal
if defined $target and not _authority_equal($target, $authority) 0 7 7
Condition33%1/3
defined $target and not _authority_equal($target, $authority)
!ll&&!rl&&r
070
MC/DC0%0/2
defined $target and not _authority_equal($target, $authority)
defined $target not _authority_equal($target, $authority)
Truth table33%1/3
A and not(B)
A= defined $targetB= not _authority_equal($target, $authority)
ABresult
0X0
100
111
785 if defined($target) && !_authority_equal($target, $authority);
786  
787 7 return;
788 }
789 }
790  
791 64 ▶ if (defined($scheme) && _ascii_lc($scheme) =~ /\Ahttps?\z/) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $scheme and _ascii_lc($scheme) =~ /\Ahttps?\z/) 64 0 64
Condition33%1/3
defined $scheme and _ascii_lc($scheme) =~ /\Ahttps?\z/
!ll&&!rl&&r
0064
MC/DC0%0/2
defined $scheme and _ascii_lc($scheme) =~ /\Ahttps?\z/
defined $scheme _ascii_lc($scheme) =~ /\Ahttps?\z/
Truth table33%1/3
A and B
A= defined $schemeB= _ascii_lc($scheme) =~ /\Ahttps?\z/
ABresult
0X0
100
111
792 64 ▶ my $effective_authority = defined($authority)
Branch: 1 branch
BranchTrueFalseTotal
defined $authority ? : 64 0 64
793 ? $authority
794 : $host;
795  
796 64 ▶ return 'http and https requests require authority'
Branch: 1 branch
BranchTrueFalseTotal
unless defined $effective_authority and length $effective_authority 0 64 64
Condition33%1/3
defined $effective_authority and length $effective_authority
!ll&&!rl&&r
0064
MC/DC0%0/2
defined $effective_authority and length $effective_authority
defined $effective_authority length $effective_authority
Truth table33%1/3
A and B
A= defined $effective_authorityB= length $effective_authority
ABresult
0X0
100
111
797 unless defined $effective_authority && length $effective_authority;
798  
799 64 ▶ return 'http and https authority must not contain userinfo'
Branch: 1 branch
BranchTrueFalseTotal
if $effective_authority =~ /@/ 1 63 64
800 if $effective_authority =~ /@/;
801  
802 63 ▶ return 'http and https :path must not contain a fragment'
Branch: 1 branch
BranchTrueFalseTotal
if $target =~ /#/ 1 62 63
803 if $target =~ /#/;
804  
805 return
806 62 ▶ if $target =~ m{\A/}
Branch: 1 branch
BranchTrueFalseTotal
if $target =~ m[\A/] or $method eq "OPTIONS" and $target eq "*" 60 2 62
Condition83%5/6
$target =~ m[\A/] or $method eq "OPTIONS" and $target eq "*"
l!l&&r!l&&!r
5912
$method eq "OPTIONS" and $target eq "*"
!ll&&!rl&&r
201
MC/DC66%2/3
$target =~ m[\A/] or $method eq "OPTIONS" and $target eq "*"
$target =~ m[\A/] $method eq "OPTIONS" $target eq "*"
Truth table75%3/4
A or B and C
A= $target =~ m[\A/]B= $method eq "OPTIONS"C= $target eq "*"
ABCresult
1XX1
0111
00X0
0100
807 || ($method eq 'OPTIONS' && $target eq '*');
808  
809 2 return 'http and https :path must start with /, except OPTIONS *';
810 }
811  
812 0 return;
813 }
814  
815 0 ▶sub _request_host_values {
Subroutine _request_host_values: not called CC=1 SCAR=6.9
816 0 my ($headers) = @_;
817  
818 return [
819 0 map { $_->[1] }
820 0 grep { _ascii_lc($_->[0]) eq 'host' }
821 @$headers
822 ];
823 }
824  
825 35 ▶sub _assert_request_semantics {
Subroutine _assert_request_semantics: called CC=2 SCAR=7.0
826 35 my ($self, $request, $operation) = @_;
827  
828 35 my $error = _request_semantic_error(
829 method => $request->method,
830 scheme => $request->scheme,
831 authority => $request->authority,
832 target => $request->target,
833 protocol => $request->protocol,
834 host_values => _message_header_values($request, 'host'),
835 );
836  
837 35 ▶ croak "$operation: $error"
Branch: 1 branch
BranchTrueFalseTotal
if defined $error 0 35 35
838 if defined $error;
839  
840 35 return;
841 }
842  
843 5 ▶sub _valid_origin_serialization {
Subroutine _valid_origin_serialization: called CC=8 SCAR=22.4
844 5 my ($value) = @_;
845  
846 5 ▶ return 0 unless defined($value) && !ref($value);
Branch: 1 branch
BranchTrueFalseTotal
unless defined $value and not ref $value 0 5 5
Condition33%1/3
defined $value and not ref $value
!ll&&!rl&&r
005
MC/DC0%0/2
defined $value and not ref $value
defined $value not ref $value
Truth table33%1/3
A and not(B)
A= defined $valueB= not ref $value
ABresult
0X0
100
111
847 5 ▶ return 0 if $value =~ /[^\x00-\x7f]/;
Branch: 1 branch
BranchTrueFalseTotal
if $value =~ /[^\x00-\x7f]/ 0 5 5
848 5 ▶ return 0 if $value =~ /[\x00-\x20\x7f]/;
Branch: 1 branch
BranchTrueFalseTotal
if $value =~ /[\x00-\x20\x7f]/ 0 5 5
849 5 ▶ return 0 if length($value) > 65_535;
Branch: 1 branch
BranchTrueFalseTotal
if length $value > 65535 0 5 5
850 5 ▶ return 1 if $value eq 'null';
Branch: 1 branch
BranchTrueFalseTotal
if $value eq "null" 0 5 5
851  
852 5 my $scheme = qr/[A-Za-z][A-Za-z0-9+.-]*/;
853 5 my $reg_name =
854 qr/(?:[A-Za-z0-9._~-]|%[0-9A-Fa-f]{2}|[!\$&'()*+,;=])+/;
855 5 my $ip_literal =
856 qr/\[(?:[0-9A-Fa-f:.]+|[vV][0-9A-Fa-f]+\.[A-Za-z0-9._~!\$&'()*+,;=:-]+)\]/;
857  
858 5 ▶ return $value =~ m{\A$scheme://(?:$ip_literal|$reg_name)(?::[0-9]+)?\z}
Branch: 1 branch
BranchTrueFalseTotal
$value =~ m[\A$scheme://(?:$ip_literal|$reg_name)(?::[0-9]+)?\z] ? : 4 1 5
859 ? 1
860 : 0;
861 }
862  
863 28 ▶sub _normalize_origins {
Subroutine _normalize_origins: called CC=8 SCAR=21.5
864 28 my ($origins) = @_;
865  
866 28 ▶ return undef unless defined $origins;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $origins 25 3 28
867  
868 3 ▶ croak 'origins must be an array reference'
Branch: 1 branch
BranchTrueFalseTotal
unless ref $origins eq "ARRAY" 0 3 3
869 unless ref($origins) eq 'ARRAY';
870  
871 3 my @normalized;
872  
873 3 for my $origin (@$origins) {
874 3 ▶ croak 'each origin must be a defined scalar'
Branch: 1 branch
BranchTrueFalseTotal
if not defined $origin or ref $origin 0 3 3
Condition33%1/3
not defined $origin or ref $origin
l!l&&r!l&&!r
003
MC/DC0%0/2
not defined $origin or ref $origin
not defined $origin ref $origin
Truth table33%1/3
not(A) or B
A= not defined $originB= ref $origin
ABresult
1X1
011
000
875 if !defined($origin) || ref($origin);
876  
877 3 my $value = "$origin";
878  
879 3 ▶ croak 'origin exceeds the RFC 9412 16-bit length limit'
Branch: 1 branch
BranchTrueFalseTotal
if length $value > 65535 0 3 3
880 if length($value) > 65_535;
881 3 ▶ croak 'origin must be an RFC 6454 ASCII serialization'
Branch: 1 branch
BranchTrueFalseTotal
unless _valid_origin_serialization($value) 1 2 3
882 unless _valid_origin_serialization($value);
883  
884 2 push @normalized, $value;
885 }
886  
887 2 return \@normalized;
888 }
889  
890 24 ▶sub _serialize_origins {
Subroutine _serialize_origins: called CC=3 SCAR=11.0
891 24 my ($origins) = @_;
892  
893 24 ▶ return undef unless defined $origins;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $origins 23 1 24
894  
895 1 my $payload = '';
896  
897 1 for my $origin (@$origins) {
898 2 $payload .= pack('n', length($origin));
899 2 $payload .= $origin;
900 }
901  
902 1 return $payload;
903 }
904  
905 28 ▶sub _new {
Subroutine _new: called CC=96 SCAR=58.9
906 28 my ($class, $role, %args) = @_;
907  
908 28 my $quic = delete $args{quic};
909 my $send_buffer_limit = exists $args{send_buffer_limit}
910 ? delete $args{send_buffer_limit}
911 28 ▶ : 4 * 1024 * 1024;
Branch: 1 branch
BranchTrueFalseTotal
exists $args{'send_buffer_limit'} ? : 2 26 28
912 my $max_field_section_size = exists $args{max_field_section_size}
913 ? delete $args{max_field_section_size}
914 28 ▶ : 65_536;
Branch: 1 branch
BranchTrueFalseTotal
exists $args{'max_field_section_size'} ? : 1 27 28
915 my $max_buffered_body_bytes = exists $args{max_buffered_body_bytes}
916 ? delete $args{max_buffered_body_bytes}
917 28 ▶ : 64 * 1024 * 1024;
Branch: 1 branch
BranchTrueFalseTotal
exists $args{'max_buffered_body_bytes'} ? : 1 27 28
918 my $max_streaming_body_bytes = exists $args{max_streaming_body_bytes}
919 ? delete $args{max_streaming_body_bytes}
920 28 ▶ : 4 * 1024 * 1024;
Branch: 1 branch
BranchTrueFalseTotal
exists $args{'max_streaming_body_bytes'} ? : 0 28 28
921 my $qpack_max_table_capacity = exists $args{qpack_max_table_capacity}
922 ? delete $args{qpack_max_table_capacity}
923 28 ▶ : 4_096;
Branch: 1 branch
BranchTrueFalseTotal
exists $args{'qpack_max_table_capacity'} ? : 2 26 28
924 my $qpack_blocked_streams = exists $args{qpack_blocked_streams}
925 ? delete $args{qpack_blocked_streams}
926 28 ▶ : 100;
Branch: 1 branch
BranchTrueFalseTotal
exists $args{'qpack_blocked_streams'} ? : 1 27 28
927 my $receive_body = exists $args{receive_body}
928 ? delete $args{receive_body}
929 28 ▶ : 'buffered';
Branch: 1 branch
BranchTrueFalseTotal
exists $args{'receive_body'} ? : 0 28 28
930 my $enable_extended_connect = exists $args{enable_extended_connect}
931 ? delete $args{enable_extended_connect}
932 28 ▶ : 0;
Branch: 1 branch
BranchTrueFalseTotal
exists $args{'enable_extended_connect'} ? : 5 23 28
933 my $enable_http_datagrams = exists $args{enable_http_datagrams}
934 ? delete $args{enable_http_datagrams}
935 28 ▶ : 0;
Branch: 1 branch
BranchTrueFalseTotal
exists $args{'enable_http_datagrams'} ? : 10 18 28
936 28 my $origins = _normalize_origins(delete $args{origins});
937 27 my $datagram_request = delete $args{datagram_request};
938 my $max_buffered_datagram_bytes =
939 exists $args{max_buffered_datagram_bytes}
940 ? delete $args{max_buffered_datagram_bytes}
941 27 ▶ : 1024 * 1024;
Branch: 1 branch
BranchTrueFalseTotal
exists $args{'max_buffered_datagram_bytes'} ? : 0 27 27
942 my $max_buffered_datagrams =
943 exists $args{max_buffered_datagrams}
944 ? delete $args{max_buffered_datagrams}
945 27 ▶ : 1024;
Branch: 1 branch
BranchTrueFalseTotal
exists $args{'max_buffered_datagrams'} ? : 1 26 27
946 27 my $has_quic_max_bidi_streams = exists $args{quic_max_bidi_streams};
947 my $quic_max_bidi_streams = $has_quic_max_bidi_streams
948 ? delete $args{quic_max_bidi_streams}
949 27 ▶ : 100;
Branch: 1 branch
BranchTrueFalseTotal
$has_quic_max_bidi_streams ? : 0 27 27
950 my $extension_settings = _normalize_extension_settings(
951 delete $args{extension_settings},
952 27 );
953 my $remembered_peer_settings_state =
954 27 delete $args{remembered_peer_settings};
955 my $remembered_local_settings_state =
956 27 delete $args{remembered_local_settings};
957 27 ▶ my $remembered_peer_settings = defined($remembered_peer_settings_state)
Branch: 1 branch
BranchTrueFalseTotal
defined $remembered_peer_settings_state ? : 3 24 27
958 ? _decode_settings_state(
959 $remembered_peer_settings_state,
960 'remembered_peer_settings',
961 )
962 : undef;
963 27 ▶ my $remembered_local_settings = defined($remembered_local_settings_state)
Branch: 1 branch
BranchTrueFalseTotal
defined $remembered_local_settings_state ? : 1 26 27
964 ? _decode_settings_state(
965 $remembered_local_settings_state,
966 'remembered_local_settings',
967 )
968 : undef;
969 27 my $on_extension_settings = delete $args{on_extension_settings};
970 27 my %callbacks;
971 27 for my $name (qw(on_request on_body on_request_end on_error)) {
972 108 ▶ next unless exists $args{$name};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $args{$name} 105 3 108
973 3 my $callback = delete $args{$name};
974 3 ▶ croak "new(): $name must be a code reference"
Branch: 1 branch
BranchTrueFalseTotal
if defined $callback and ref $callback ne "CODE" 0 3 3
Condition33%1/3
defined $callback and ref $callback ne "CODE"
!ll&&!rl&&r
030
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"
ABresult
0X0
100
111
975 if defined($callback) && ref($callback) ne 'CODE';
976 3 ▶ $callbacks{$name} = $callback if defined $callback;
Branch: 1 branch
BranchTrueFalseTotal
if defined $callback 3 0 3
977 }
978  
979 27 ▶ croak 'new(): request callbacks are only valid for a server connection'
Branch: 1 branch
BranchTrueFalseTotal
if $role ne "server" and keys %callbacks 0 27 27
Condition66%2/3
$role ne "server" and keys %callbacks
!ll&&!rl&&r
12150
MC/DC0%0/2
$role ne "server" and keys %callbacks
$role ne "server" keys %callbacks
Truth table66%2/3
A and B
A= $role ne "server"B= keys %callbacks
ABresult
0X0
100
111
980 if $role ne 'server' && keys %callbacks;
981  
982 my $extension_stream_handlers =
983 _normalize_extension_stream_handlers(
984 delete $args{extension_stream_handlers},
985 27 );
986  
987 27 ▶ croak 'remembered_peer_settings is only valid for a client connection'
Branch: 1 branch
BranchTrueFalseTotal
if $role ne "client" and defined $remembered_peer_settings 0 27 27
Condition66%2/3
$role ne "client" and defined $remembered_peer_settings
!ll&&!rl&&r
15120
MC/DC0%0/2
$role ne "client" and defined $remembered_peer_settings
$role ne "client" defined $remembered_peer_settings
Truth table66%2/3
A and B
A= $role ne "client"B= defined $remembered_peer_settings
ABresult
0X0
100
111
988 if $role ne 'client' && defined $remembered_peer_settings;
989 27 ▶ croak 'remembered_local_settings is only valid for a server connection'
Branch: 1 branch
BranchTrueFalseTotal
if $role ne "server" and defined $remembered_local_settings 0 27 27
Condition66%2/3
$role ne "server" and defined $remembered_local_settings
!ll&&!rl&&r
12150
MC/DC0%0/2
$role ne "server" and defined $remembered_local_settings
$role ne "server" defined $remembered_local_settings
Truth table66%2/3
A and B
A= $role ne "server"B= defined $remembered_local_settings
ABresult
0X0
100
111
990 if $role ne 'server' && defined $remembered_local_settings;
991  
992 27 ▶ croak 'on_extension_settings must be a code reference'
Branch: 1 branch
BranchTrueFalseTotal
if defined $on_extension_settings and ref $on_extension_settings ne "CODE" 0 27 27
Condition66%2/3
defined $on_extension_settings and ref $on_extension_settings ne "CODE"
!ll&&!rl&&r
2520
MC/DC0%0/2
defined $on_extension_settings and ref $on_extension_settings ne "CODE"
defined $on_extension_settings ref $on_extension_settings ne "CODE"
Truth table66%2/3
A and B
A= defined $on_extension_settingsB= ref $on_extension_settings ne "CODE"
ABresult
0X0
100
111
993 if defined($on_extension_settings)
994 && ref($on_extension_settings) ne 'CODE';
995  
996 27 ▶ croak 'enable_extended_connect must be 0 or 1'
Branch: 1 branch
BranchTrueFalseTotal
if not defined $enable_extended_connect or ref $enable_extended_connect or not "$enable_extended_connect" =~ /\A[01]\z/ 0 27 27
Condition33%2/6
not defined $enable_extended_connect or ref $enable_extended_connect or not "$enable_extended_connect" =~ /\A[01]\z/
l!l&&r!l&&!r
0027
not defined $enable_extended_connect or ref $enable_extended_connect
l!l&&r!l&&!r
0027
MC/DC0%0/3
not defined $enable_extended_connect or ref $enable_extended_connect or not "$enable_extended_connect" =~ /\A[01]\z/
not defined $enable_extended_connect ref $enable_extended_connect not "$enable_extended_connect" =~ /\A[01]\z/
Truth table25%1/4
not(A) or B or not(C)
A= not defined $enable_extended_connectB= ref $enable_extended_connectC= not "$enable_extended_connect" =~ /\A[01]\z/
ABCresult
1XX1
01X1
0011
0000
997 if !defined($enable_extended_connect)
998 || ref($enable_extended_connect)
999 || "$enable_extended_connect" !~ /\A[01]\z/;
1000 27 ▶ croak 'enable_extended_connect is only valid for a server connection'
Branch: 1 branch
BranchTrueFalseTotal
if $role ne "server" and $enable_extended_connect 0 27 27
Condition66%2/3
$role ne "server" and $enable_extended_connect
!ll&&!rl&&r
12150
MC/DC0%0/2
$role ne "server" and $enable_extended_connect
$role ne "server" $enable_extended_connect
Truth table66%2/3
A and B
A= $role ne "server"B= $enable_extended_connect
ABresult
0X0
100
111
1001 if $role ne 'server' && $enable_extended_connect;
1002  
1003 27 ▶ croak 'enable_http_datagrams must be 0 or 1'
Branch: 1 branch
BranchTrueFalseTotal
if not defined $enable_http_datagrams or ref $enable_http_datagrams or not "$enable_http_datagrams" =~ /\A[01]\z/ 0 27 27
Condition33%2/6
not defined $enable_http_datagrams or ref $enable_http_datagrams or not "$enable_http_datagrams" =~ /\A[01]\z/
l!l&&r!l&&!r
0027
not defined $enable_http_datagrams or ref $enable_http_datagrams
l!l&&r!l&&!r
0027
MC/DC0%0/3
not defined $enable_http_datagrams or ref $enable_http_datagrams or not "$enable_http_datagrams" =~ /\A[01]\z/
not defined $enable_http_datagrams ref $enable_http_datagrams not "$enable_http_datagrams" =~ /\A[01]\z/
Truth table25%1/4
not(A) or B or not(C)
A= not defined $enable_http_datagramsB= ref $enable_http_datagramsC= not "$enable_http_datagrams" =~ /\A[01]\z/
ABCresult
1XX1
01X1
0011
0000
1004 if !defined($enable_http_datagrams)
1005 || ref($enable_http_datagrams)
1006 || "$enable_http_datagrams" !~ /\A[01]\z/;
1007 27 ▶ croak 'datagram_request must be a code reference'
Branch: 1 branch
BranchTrueFalseTotal
if defined $datagram_request and ref $datagram_request ne "CODE" 0 27 27
Condition66%2/3
defined $datagram_request and ref $datagram_request ne "CODE"
!ll&&!rl&&r
2340
MC/DC0%0/2
defined $datagram_request and ref $datagram_request ne "CODE"
defined $datagram_request ref $datagram_request ne "CODE"
Truth table66%2/3
A and B
A= defined $datagram_requestB= ref $datagram_request ne "CODE"
ABresult
0X0
100
111
1008 if defined($datagram_request) && ref($datagram_request) ne 'CODE';
1009 27 ▶ croak 'datagram_request is only valid for a server connection'
Branch: 1 branch
BranchTrueFalseTotal
if $role ne "server" and defined $datagram_request 0 27 27
Condition66%2/3
$role ne "server" and defined $datagram_request
!ll&&!rl&&r
12150
MC/DC0%0/2
$role ne "server" and defined $datagram_request
$role ne "server" defined $datagram_request
Truth table66%2/3
A and B
A= $role ne "server"B= defined $datagram_request
ABresult
0X0
100
111
1010 if $role ne 'server' && defined($datagram_request);
1011 27 ▶ croak 'origins is only valid for a server connection'
Branch: 1 branch
BranchTrueFalseTotal
if $role ne "server" and defined $origins 1 26 27
Condition100%3/3
$role ne "server" and defined $origins
!ll&&!rl&&r
12141
MC/DC100%2/2
$role ne "server" and defined $origins
$role ne "server" defined $origins
Truth table100%3/3
A and B
A= $role ne "server"B= defined $origins
ABresult
0X0
100
111
1012 if $role ne 'server' && defined($origins);
1013  
1014 26 ▶ croak 'quic_max_bidi_streams must be a non-negative integer'
Branch: 1 branch
BranchTrueFalseTotal
if not defined $quic_max_bidi_streams or ref $quic_max_bidi_streams or not "$quic_max_bidi_streams" =~ /\A[0-9]+\z/ 0 26 26
Condition33%2/6
not defined $quic_max_bidi_streams or ref $quic_max_bidi_streams or not "$quic_max_bidi_streams" =~ /\A[0-9]+\z/
l!l&&r!l&&!r
0026
not defined $quic_max_bidi_streams or ref $quic_max_bidi_streams
l!l&&r!l&&!r
0026
MC/DC0%0/3
not defined $quic_max_bidi_streams or ref $quic_max_bidi_streams or not "$quic_max_bidi_streams" =~ /\A[0-9]+\z/
not defined $quic_max_bidi_streams ref $quic_max_bidi_streams not "$quic_max_bidi_streams" =~ /\A[0-9]+\z/
Truth table25%1/4
not(A) or B or not(C)
A= not defined $quic_max_bidi_streamsB= ref $quic_max_bidi_streamsC= not "$quic_max_bidi_streams" =~ /\A[0-9]+\z/
ABCresult
1XX1
01X1
0011
0000
1015 if !defined($quic_max_bidi_streams)
1016 || ref($quic_max_bidi_streams)
1017 || "$quic_max_bidi_streams" !~ /\A[0-9]+\z/;
1018 26 ▶ croak 'quic_max_bidi_streams is only valid for server connections'
Branch: 1 branch
BranchTrueFalseTotal
if $role ne "server" and $has_quic_max_bidi_streams 0 26 26
Condition66%2/3
$role ne "server" and $has_quic_max_bidi_streams
!ll&&!rl&&r
12140
MC/DC0%0/2
$role ne "server" and $has_quic_max_bidi_streams
$role ne "server" $has_quic_max_bidi_streams
Truth table66%2/3
A and B
A= $role ne "server"B= $has_quic_max_bidi_streams
ABresult
0X0
100
111
1019 if $role ne 'server' && $has_quic_max_bidi_streams;
1020  
1021 26 ▶ croak 'quic is required'
Branch: 1 branch
BranchTrueFalseTotal
unless defined $quic 0 26 26
1022 unless defined $quic;
1023 26 ▶ croak 'quic must be a Net::QUIC::Connection object'
Branch: 1 branch
BranchTrueFalseTotal
unless builtin::blessed($quic) and $quic->isa("Net::QUIC::Connection") 0 26 26
Condition33%1/3
builtin::blessed($quic) and $quic->isa("Net::QUIC::Connection")
!ll&&!rl&&r
0026
MC/DC0%0/2
builtin::blessed($quic) and $quic->isa("Net::QUIC::Connection")
builtin::blessed($quic) $quic->isa("Net::QUIC::Connection")
Truth table33%1/3
A and B
A= builtin::blessed($quic)B= $quic->isa("Net::QUIC::Connection")
ABresult
0X0
100
111
1024 unless blessed($quic) && $quic->isa('Net::QUIC::Connection');
1025 26 ▶ croak 'enable_http_datagrams requires QUIC DATAGRAM receive support'
Branch: 1 branch
BranchTrueFalseTotal
if $enable_http_datagrams and not $quic->can_receive_datagram 1 25 26
Condition100%3/3
$enable_http_datagrams and not $quic->can_receive_datagram
!ll&&!rl&&r
1691
MC/DC100%2/2
$enable_http_datagrams and not $quic->can_receive_datagram
$enable_http_datagrams not $quic->can_receive_datagram
Truth table100%3/3
A and not(B)
A= $enable_http_datagramsB= not $quic->can_receive_datagram
ABresult
0X0
100
111
1026 if $enable_http_datagrams && !$quic->can_receive_datagram;
1027  
1028 25 ▶ croak 'send_buffer_limit must be a positive integer'
Branch: 1 branch
BranchTrueFalseTotal
unless defined $send_buffer_limit and not ref $send_buffer_limit and $send_buffer_limit =~ /\A[0-9]+\z/ and $send_buffer_limit > 0 0 25 25
Condition33%3/9
defined $send_buffer_limit and not ref $send_buffer_limit and $send_buffer_limit =~ /\A[0-9]+\z/ and $send_buffer_limit > 0
!ll&&!rl&&r
0025
defined $send_buffer_limit and not ref $send_buffer_limit and $send_buffer_limit =~ /\A[0-9]+\z/
!ll&&!rl&&r
0025
defined $send_buffer_limit and not ref $send_buffer_limit
!ll&&!rl&&r
0025
MC/DC0%0/4
defined $send_buffer_limit and not ref $send_buffer_limit and $send_buffer_limit =~ /\A[0-9]+\z/ and $send_buffer_limit > 0
defined $send_buffer_limit not ref $send_buffer_limit $send_buffer_limit =~ /\A[0-9]+\z/ $send_buffer_limit > 0
Truth table20%1/5
A and not(B) and C and D
A= defined $send_buffer_limitB= not ref $send_buffer_limitC= $send_buffer_limit =~ /\A[0-9]+\z/D= $send_buffer_limit > 0
ABCDresult
0XXX0
10XX0
110X0
11100
11111
1029 unless defined($send_buffer_limit)
1030 && !ref($send_buffer_limit)
1031 && $send_buffer_limit =~ /\A[0-9]+\z/
1032 && $send_buffer_limit > 0;
1033 25 ▶ croak 'max_buffered_datagram_bytes must be a positive integer'
Branch: 1 branch
BranchTrueFalseTotal
unless defined $max_buffered_datagram_bytes and not ref $max_buffered_datagram_bytes and $max_buffered_datagram_bytes =~ /\A[0-9]+\z/ and $max_buffered_datagram_bytes > 0 0 25 25
Condition33%3/9
defined $max_buffered_datagram_bytes and not ref $max_buffered_datagram_bytes and $max_buffered_datagram_bytes =~ /\A[0-9]+\z/ and $max_buffered_datagram_bytes > 0
!ll&&!rl&&r
0025
defined $max_buffered_datagram_bytes and not ref $max_buffered_datagram_bytes and $max_buffered_datagram_bytes =~ /\A[0-9]+\z/
!ll&&!rl&&r
0025
defined $max_buffered_datagram_bytes and not ref $max_buffered_datagram_bytes
!ll&&!rl&&r
0025
MC/DC0%0/4
defined $max_buffered_datagram_bytes and not ref $max_buffered_datagram_bytes and $max_buffered_datagram_bytes =~ /\A[0-9]+\z/ and $max_buffered_datagram_bytes > 0
defined $max_buffered_datagram_bytes not ref $max_buffered_datagram_bytes $max_buffered_datagram_bytes =~ /\A[0-9]+\z/ $max_buffered_datagram_bytes > 0
Truth table20%1/5
A and not(B) and C and D
A= defined $max_buffered_datagram_bytesB= not ref $max_buffered_datagram_bytesC= $max_buffered_datagram_bytes =~ /\A[0-9]+\z/D= $max_buffered_datagram_bytes > 0
ABCDresult
0XXX0
10XX0
110X0
11100
11111
1034 unless defined($max_buffered_datagram_bytes)
1035 && !ref($max_buffered_datagram_bytes)
1036 && $max_buffered_datagram_bytes =~ /\A[0-9]+\z/
1037 && $max_buffered_datagram_bytes > 0;
1038 25 ▶ croak 'max_buffered_datagrams must be a positive integer'
Branch: 1 branch
BranchTrueFalseTotal
unless defined $max_buffered_datagrams and not ref $max_buffered_datagrams and $max_buffered_datagrams =~ /\A[0-9]+\z/ and $max_buffered_datagrams > 0 0 25 25
Condition33%3/9
defined $max_buffered_datagrams and not ref $max_buffered_datagrams and $max_buffered_datagrams =~ /\A[0-9]+\z/ and $max_buffered_datagrams > 0
!ll&&!rl&&r
0025
defined $max_buffered_datagrams and not ref $max_buffered_datagrams and $max_buffered_datagrams =~ /\A[0-9]+\z/
!ll&&!rl&&r
0025
defined $max_buffered_datagrams and not ref $max_buffered_datagrams
!ll&&!rl&&r
0025
MC/DC0%0/4
defined $max_buffered_datagrams and not ref $max_buffered_datagrams and $max_buffered_datagrams =~ /\A[0-9]+\z/ and $max_buffered_datagrams > 0
defined $max_buffered_datagrams not ref $max_buffered_datagrams $max_buffered_datagrams =~ /\A[0-9]+\z/ $max_buffered_datagrams > 0
Truth table20%1/5
A and not(B) and C and D
A= defined $max_buffered_datagramsB= not ref $max_buffered_datagramsC= $max_buffered_datagrams =~ /\A[0-9]+\z/D= $max_buffered_datagrams > 0
ABCDresult
0XXX0
10XX0
110X0
11100
11111
1039 unless defined($max_buffered_datagrams)
1040 && !ref($max_buffered_datagrams)
1041 && $max_buffered_datagrams =~ /\A[0-9]+\z/
1042 && $max_buffered_datagrams > 0;
1043  
1044 25 for my $limit (
1045 [ max_field_section_size => $max_field_section_size ],
1046 [ max_buffered_body_bytes => $max_buffered_body_bytes ],
1047 [ max_streaming_body_bytes => $max_streaming_body_bytes ],
1048 ) {
1049 75 ▶ croak "$limit->[0] must be a positive integer"
Branch: 1 branch
BranchTrueFalseTotal
unless defined $limit->[1] and not ref $limit->[1] and $limit->[1] =~ /\A[0-9]+\z/ and $limit->[1] > 0 0 75 75
Condition33%3/9
defined $limit->[1] and not ref $limit->[1] and $limit->[1] =~ /\A[0-9]+\z/ and $limit->[1] > 0
!ll&&!rl&&r
0075
defined $limit->[1] and not ref $limit->[1] and $limit->[1] =~ /\A[0-9]+\z/
!ll&&!rl&&r
0075
defined $limit->[1] and not ref $limit->[1]
!ll&&!rl&&r
0075
MC/DC0%0/4
defined $limit->[1] and not ref $limit->[1] and $limit->[1] =~ /\A[0-9]+\z/ and $limit->[1] > 0
defined $limit->[1] not ref $limit->[1] $limit->[1] =~ /\A[0-9]+\z/ $limit->[1] > 0
Truth table20%1/5
A and not(B) and C and D
A= defined $limit->[1]B= not ref $limit->[1]C= $limit->[1] =~ /\A[0-9]+\z/D= $limit->[1] > 0
ABCDresult
0XXX0
10XX0
110X0
11100
11111
1050 unless defined($limit->[1])
1051 && !ref($limit->[1])
1052 && $limit->[1] =~ /\A[0-9]+\z/
1053 && $limit->[1] > 0;
1054 }
1055  
1056 25 for my $setting (
1057 [ qpack_max_table_capacity => $qpack_max_table_capacity ],
1058 [ qpack_blocked_streams => $qpack_blocked_streams ],
1059 ) {
1060 50 ▶ croak "$setting->[0] must be a non-negative integer"
Branch: 1 branch
BranchTrueFalseTotal
unless defined $setting->[1] and not ref $setting->[1] and $setting->[1] =~ /\A[0-9]+\z/ 0 50 50
Condition33%2/6
defined $setting->[1] and not ref $setting->[1] and $setting->[1] =~ /\A[0-9]+\z/
!ll&&!rl&&r
0050
defined $setting->[1] and not ref $setting->[1]
!ll&&!rl&&r
0050
MC/DC0%0/3
defined $setting->[1] and not ref $setting->[1] and $setting->[1] =~ /\A[0-9]+\z/
defined $setting->[1] not ref $setting->[1] $setting->[1] =~ /\A[0-9]+\z/
Truth table25%1/4
A and not(B) and C
A= defined $setting->[1]B= not ref $setting->[1]C= $setting->[1] =~ /\A[0-9]+\z/
ABCresult
0XX0
10X0
1100
1111
1061 unless defined($setting->[1])
1062 && !ref($setting->[1])
1063 && $setting->[1] =~ /\A[0-9]+\z/;
1064 }
1065  
1066 25 ▶ croak 'max_field_section_size exceeds the HTTP/3 varint maximum'
Branch: 1 branch
BranchTrueFalseTotal
if _exceeds_http3_varint($max_field_section_size) 0 25 25
1067 if _exceeds_http3_varint($max_field_section_size);
1068 25 ▶ croak 'qpack_max_table_capacity exceeds the HTTP/3 varint maximum'
Branch: 1 branch
BranchTrueFalseTotal
if _exceeds_http3_varint($qpack_max_table_capacity) 1 24 25
1069 if _exceeds_http3_varint($qpack_max_table_capacity);
1070 24 ▶ croak 'qpack_blocked_streams exceeds the HTTP/3 varint maximum'
Branch: 1 branch
BranchTrueFalseTotal
if _exceeds_http3_varint($qpack_blocked_streams) 0 24 24
1071 if _exceeds_http3_varint($qpack_blocked_streams);
1072  
1073 24 ▶ croak 'receive_body must be buffered or stream'
Branch: 1 branch
BranchTrueFalseTotal
if not defined $receive_body or ref $receive_body or $receive_body ne "buffered" and $receive_body ne "stream" 0 24 24
Condition33%3/9
not defined $receive_body or ref $receive_body or $receive_body ne "buffered" and $receive_body ne "stream"
l!l&&r!l&&!r
0024
not defined $receive_body or ref $receive_body
l!l&&r!l&&!r
0024
$receive_body ne "buffered" and $receive_body ne "stream"
!ll&&!rl&&r
2400
MC/DC0%0/4
not defined $receive_body or ref $receive_body or $receive_body ne "buffered" and $receive_body ne "stream"
not defined $receive_body ref $receive_body $receive_body ne "buffered" $receive_body ne "stream"
Truth table20%1/5
not(A) or B or C and D
A= not defined $receive_bodyB= ref $receive_bodyC= $receive_body ne "buffered"D= $receive_body ne "stream"
ABCDresult
1XXX1
01XX1
00111
000X0
00100
1074 if !defined($receive_body)
1075 || ref($receive_body)
1076 || ($receive_body ne 'buffered' && $receive_body ne 'stream');
1077  
1078 24 ▶ croak 'unknown connection option: ' . join(', ', sort keys %args)
Branch: 1 branch
BranchTrueFalseTotal
if %args 0 24 24
1079 if %args;
1080  
1081 24 my %local_settings = (
1082 1 => "$qpack_max_table_capacity",
1083 6 => "$max_field_section_size",
1084 7 => "$qpack_blocked_streams",
1085 );
1086 24 ▶ $local_settings{8} = '1' if $enable_extended_connect;
Branch: 1 branch
BranchTrueFalseTotal
if $enable_extended_connect 5 19 24
1087 24 ▶ $local_settings{51} = '1' if $enable_http_datagrams;
Branch: 1 branch
BranchTrueFalseTotal
if $enable_http_datagrams 9 15 24
1088 24 @local_settings{keys %$extension_settings}
1089 = values %$extension_settings;
1090  
1091 24 my $origin_list = _serialize_origins($origins);
1092  
1093 24 ▶ if (defined $remembered_local_settings) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $remembered_local_settings) 1 23 24
1094 1 my $compatibility_error = _settings_compatibility_error(
1095 $remembered_local_settings,
1096 \%local_settings,
1097 );
1098  
1099 1 ▶ croak "remembered_local_settings is incompatible with current HTTP/3 settings: "
Branch: 1 branch
BranchTrueFalseTotal
if defined $compatibility_error 0 1 1
1100 . $compatibility_error
1101 if defined $compatibility_error;
1102 }
1103  
1104 24 ▶ my $native = $role eq 'server'
Branch: 1 branch
BranchTrueFalseTotal
$role eq 'server' ? : 12 12 24
1105 ? Unblock::HTTP3::_Native->server(
1106 $max_field_section_size,
1107 $qpack_max_table_capacity,
1108 $qpack_blocked_streams,
1109 $enable_extended_connect,
1110 $enable_http_datagrams,
1111 $origin_list,
1112 )
1113 : Unblock::HTTP3::_Native->client(
1114 $max_field_section_size,
1115 $qpack_max_table_capacity,
1116 $qpack_blocked_streams,
1117 0,
1118 $enable_http_datagrams,
1119 );
1120  
1121 24 ▶ $native->set_max_client_streams_bidi($quic_max_bidi_streams)
Branch: 1 branch
BranchTrueFalseTotal
if $role eq "server" 12 12 24
1122 if $role eq 'server';
1123  
1124 return bless {
1125 role => $role,
1126 quic => $quic,
1127 native => $native,
1128 send_buffer_limit => 0 + $send_buffer_limit,
1129 max_field_section_size => 0 + $max_field_section_size,
1130 max_buffered_body_bytes => 0 + $max_buffered_body_bytes,
1131 max_streaming_body_bytes => 0 + $max_streaming_body_bytes,
1132 qpack_max_table_capacity => 0 + $qpack_max_table_capacity,
1133 qpack_blocked_streams => 0 + $qpack_blocked_streams,
1134 quic_max_bidi_streams => 0 + $quic_max_bidi_streams,
1135 native_max_client_streams_bidi => 0 + $quic_max_bidi_streams,
1136 local_settings => \%local_settings,
1137 remembered_peer_settings => $remembered_peer_settings,
1138 remembered_local_settings => $remembered_local_settings,
1139 peer_settings_wire => {},
1140 peer_max_field_section_size => defined($remembered_peer_settings)
1141 ? _effective_setting($remembered_peer_settings, 6)
1142 : $HTTP3_MAX_VARINT,
1143 receive_body_mode => $receive_body,
1144 enable_extended_connect => $enable_extended_connect ? 1 : 0,
1145 peer_enable_connect_protocol => defined($remembered_peer_settings)
1146 && _effective_setting($remembered_peer_settings, 8) eq '1'
1147 ? 1 : 0,
1148 enable_http_datagrams => $enable_http_datagrams ? 1 : 0,
1149 origins => $origins,
1150 peer_origins => undef,
1151 peer_origin_pending => [],
1152 peer_h3_datagram => defined($remembered_peer_settings)
1153 && _effective_setting($remembered_peer_settings, 51) eq '1'
1154 ? 1 : 0,
1155 datagram_request => $datagram_request,
1156 max_buffered_datagram_bytes => 0 + $max_buffered_datagram_bytes,
1157 max_buffered_datagrams => 0 + $max_buffered_datagrams,
1158 datagram_buffered_bytes => 0,
1159 datagram_buffered_count => 0,
1160 datagram_receive_drops => 0,
1161 extension_settings => $extension_settings,
1162 peer_extension_settings => defined($remembered_peer_settings)
1163 ? {
1164 map {
1165 3 $_ => $remembered_peer_settings->{$_}
1166 } grep {
1167 24 ▶ _is_peer_extension_setting_id($_)
Branch: 7 branches
BranchTrueFalseTotal
defined $remembered_peer_settings ? : 3 21 24
$enable_extended_connect ? : 5 19 24
defined $remembered_peer_settings && _effective_setting($remembered_peer_settings, 8) eq '1' ? : 3 21 24
$enable_http_datagrams ? : 9 15 24
defined $remembered_peer_settings && _effective_setting($remembered_peer_settings, 51) eq '1' ? : 3 21 24
defined $remembered_peer_settings ? : 3 21 24
defined $remembered_peer_settings ? : 3 21 24
Condition66%4/6
defined $remembered_peer_settings and _effective_setting($remembered_peer_settings, 8) eq 1
!ll&&!rl&&r
2103
defined $remembered_peer_settings and _effective_setting($remembered_peer_settings, 51) eq 1
!ll&&!rl&&r
2103
MC/DC50%1/2
defined $remembered_peer_settings and _effective_setting($remembered_peer_settings, 8) eq 1
defined $remembered_peer_settings _effective_setting($remembered_peer_settings, 8) eq 1
MC/DC50%1/2
defined $remembered_peer_settings and _effective_setting($remembered_peer_settings, 51) eq 1
defined $remembered_peer_settings _effective_setting($remembered_peer_settings, 51) eq 1
Truth table66%2/3
A and B
A= defined $remembered_peer_settingsB= _effective_setting($remembered_peer_settings, 8) eq 1
ABresult
0X0
100
111
Truth table66%2/3
A and B
A= defined $remembered_peer_settingsB= _effective_setting($remembered_peer_settings, 51) eq 1
ABresult
0X0
100
111
1168 } keys %$remembered_peer_settings
1169 }
1170 : {},
1171 peer_settings_received => 0,
1172 peer_settings_initialized => defined($remembered_peer_settings) ? 1 : 0,
1173 peer_settings_parser => {},
1174 on_extension_settings => $on_extension_settings,
1175 callbacks => \%callbacks,
1176 control_settings_rewritten => 0,
1177 control_settings_delta => 0,
1178 control_settings_pending => undef,
1179 extension_stream_handlers => $extension_stream_handlers,
1180 extension_stream_objects => {},
1181 peer_uni_probe => {},
1182 core_uni_streams => {},
1183 ignored_uni_streams => {},
1184 started => 0,
1185 early_data_started => 0,
1186 early_data_status => $quic->early_data_status,
1187 early_data_rollback_done => 0,
1188 failed => 0,
1189 error => undef,
1190 error_code => undef,
1191 shutdown_notice_sent => 0,
1192 shutdown_started => 0,
1193 remote_shutdown_id => undef,
1194 servicing => 0,
1195 service_again => 0,
1196 streams => {},
1197 messages => {},
1198 outgoing => {},
1199 stream_lifecycle => {},
1200 building => {},
1201 transactions => {},
1202 ready_transactions => [],
1203 pending_early_transactions => [],
1204 pending_early_datagrams => {},
1205 ready_informational => [],
1206 output_finished => {},
1207 response_sent => {},
1208 }, $class;
1209 }
1210  
1211 46 ▶sub role {
Subroutine role: called CC=2 SCAR=7.1
Pod undocumented
1212 46 my ($self, @args) = @_;
1213 46 ▶ croak 'role() does not accept arguments' if @args;
Branch: 1 branch
BranchTrueFalseTotal
if @args 0 46 46
1214 46 return $self->{role};
1215 }
1216  
1217 1 ▶sub quic {
Subroutine quic: called CC=2 SCAR=7.1
Pod undocumented
1218 1 my ($self, @args) = @_;
1219 1 ▶ croak 'quic() does not accept arguments' if @args;
Branch: 1 branch
BranchTrueFalseTotal
if @args 0 1 1
1220 1 return $self->{quic};
1221 }
1222  
1223 0 ▶sub nghttp3_version {
Subroutine nghttp3_version: not called CC=2 SCAR=17.9
Pod undocumented
1224 0 my ($self, @args) = @_;
1225 0 ▶ croak 'nghttp3_version() does not accept arguments' if @args;
Branch: 1 branch
BranchTrueFalseTotal
if @args 0 0 0
1226 0 return Unblock::HTTP3::_Native::nghttp3_version();
1227 }
1228  
1229 1 ▶sub early_data_status {
Subroutine early_data_status: called CC=3 SCAR=11.4
Pod undocumented
1230 1 my ($self, @args) = @_;
1231 1 ▶ croak 'early_data_status() does not accept arguments' if @args;
Branch: 1 branch
BranchTrueFalseTotal
if @args 0 1 1
1232 1 ▶ $self->_sync_early_data_status if $self->{started};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"started"} 1 0 1
1233 1 return $self->{quic}->early_data_status;
1234 }
1235  
1236 3 ▶sub started {
Subroutine started: called CC=3 SCAR=11.7
Pod undocumented
1237 3 my ($self, @args) = @_;
1238 3 ▶ croak 'started() does not accept arguments' if @args;
Branch: 1 branch
BranchTrueFalseTotal
if @args 0 3 3
1239 3 ▶ return $self->{started} ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$self->{'started'} ? : 3 0 3
1240 }
1241  
1242 34 ▶sub failed {
Subroutine failed: called CC=3 SCAR=11.1
Pod undocumented
1243 34 my ($self, @args) = @_;
1244 34 ▶ croak 'failed() does not accept arguments' if @args;
Branch: 1 branch
BranchTrueFalseTotal
if @args 0 34 34
1245 34 ▶ return $self->{failed} ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$self->{'failed'} ? : 11 23 34
1246 }
1247  
1248 7 ▶sub error {
Subroutine error: called CC=2 SCAR=7.1
Pod undocumented
1249 7 my ($self, @args) = @_;
1250 7 ▶ croak 'error() does not accept arguments' if @args;
Branch: 1 branch
BranchTrueFalseTotal
if @args 0 7 7
1251 7 return $self->{error};
1252 }
1253  
1254 11 ▶sub error_code {
Subroutine error_code: called CC=2 SCAR=7.1
Pod undocumented
1255 11 my ($self, @args) = @_;
1256 11 ▶ croak 'error_code() does not accept arguments' if @args;
Branch: 1 branch
BranchTrueFalseTotal
if @args 0 11 11
1257 11 return $self->{error_code};
1258 }
1259  
1260 0 ▶sub max_field_section_size {
Subroutine max_field_section_size: not called CC=2 SCAR=17.9
Pod undocumented
1261 0 my ($self, @args) = @_;
1262 0 ▶ croak 'max_field_section_size() does not accept arguments' if @args;
Branch: 1 branch
BranchTrueFalseTotal
if @args 0 0 0
1263 0 return $self->{max_field_section_size};
1264 }
1265  
1266 1 ▶sub max_buffered_body_bytes {
Subroutine max_buffered_body_bytes: called CC=2 SCAR=7.1
Pod undocumented
1267 1 my ($self, @args) = @_;
1268 1 ▶ croak 'max_buffered_body_bytes() does not accept arguments' if @args;
Branch: 1 branch
BranchTrueFalseTotal
if @args 0 1 1
1269 1 return $self->{max_buffered_body_bytes};
1270 }
1271  
1272 0 ▶sub max_streaming_body_bytes {
Subroutine max_streaming_body_bytes: not called CC=2 SCAR=17.9
Pod undocumented
1273 0 my ($self, @args) = @_;
1274 0 ▶ croak 'max_streaming_body_bytes() does not accept arguments' if @args;
Branch: 1 branch
BranchTrueFalseTotal
if @args 0 0 0
1275 0 return $self->{max_streaming_body_bytes};
1276 }
1277  
1278 2 ▶sub qpack_max_table_capacity {
Subroutine qpack_max_table_capacity: called CC=2 SCAR=7.1
Pod undocumented
1279 2 my ($self, @args) = @_;
1280 2 ▶ croak 'qpack_max_table_capacity() does not accept arguments' if @args;
Branch: 1 branch
BranchTrueFalseTotal
if @args 0 2 2
1281 2 return $self->{qpack_max_table_capacity};
1282 }
1283  
1284 2 ▶sub qpack_blocked_streams {
Subroutine qpack_blocked_streams: called CC=2 SCAR=7.1
Pod undocumented
1285 2 my ($self, @args) = @_;
1286 2 ▶ croak 'qpack_blocked_streams() does not accept arguments' if @args;
Branch: 1 branch
BranchTrueFalseTotal
if @args 0 2 2
1287 2 return $self->{qpack_blocked_streams};
1288 }
1289  
1290 2 ▶sub local_settings_state {
Subroutine local_settings_state: called CC=2 SCAR=7.1
Pod undocumented
1291 2 my ($self, @args) = @_;
1292 2 ▶ croak 'local_settings_state() does not accept arguments' if @args;
Branch: 1 branch
BranchTrueFalseTotal
if @args 0 2 2
1293 2 return _encode_settings_state($self->{local_settings});
1294 }
1295  
1296 2 ▶sub peer_settings_state {
Subroutine peer_settings_state: called CC=3 SCAR=11.0
Pod undocumented
1297 2 my ($self, @args) = @_;
1298 2 ▶ croak 'peer_settings_state() does not accept arguments' if @args;
Branch: 1 branch
BranchTrueFalseTotal
if @args 0 2 2
1299 2 ▶ return unless $self->{peer_settings_received};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"peer_settings_received"} 1 1 2
1300 1 return _encode_settings_state($self->{peer_settings_wire});
1301 }
1302  
1303 3 ▶sub using_remembered_peer_settings {
Subroutine using_remembered_peer_settings: called CC=4 SCAR=14.2
Pod undocumented
1304 3 my ($self, @args) = @_;
1305 3 ▶ croak 'using_remembered_peer_settings() does not accept arguments'
Branch: 1 branch
BranchTrueFalseTotal
if @args 0 3 3
1306 if @args;
1307  
1308 return defined($self->{remembered_peer_settings})
1309 && !$self->{peer_settings_received}
1310 3 ▶ ? 1
Branch: 1 branch
BranchTrueFalseTotal
defined $self->{'remembered_peer_settings'} && !$self->{'peer_settings_received'} ? : 2 1 3
Condition66%2/3
defined $self->{"remembered_peer_settings"} and not $self->{"peer_settings_received"}
!ll&&!rl&&r
012
MC/DC50%1/2
defined $self->{"remembered_peer_settings"} and not $self->{"peer_settings_received"}
defined $self->{"remembered_peer_settings"} not $self->{"peer_settings_received"}
Truth table66%2/3
A and not(B)
A= defined $self->{"remembered_peer_settings"}B= not $self->{"peer_settings_received"}
ABresult
0X0
100
111
1311 : 0;
1312 }
1313  
1314 0 ▶sub extension_settings {
Subroutine extension_settings: not called CC=2 SCAR=17.9
Pod undocumented
1315 0 my ($self, @args) = @_;
1316 0 ▶ croak 'extension_settings() does not accept arguments' if @args;
Branch: 1 branch
BranchTrueFalseTotal
if @args 0 0 0
1317 0 return { %{ $self->{extension_settings} } };
1318 }
1319  
1320 0 ▶sub extension_setting {
Subroutine extension_setting: not called CC=4 SCAR=30.0
Pod undocumented
1321 0 my ($self, $id, @args) = @_;
1322  
1323 0 $id = _normalize_http3_varint(
1324 $id,
1325 'extension setting identifier',
1326 );
1327  
1328 0 _assert_extension_setting_id($id);
1329  
1330 0 ▶ return $self->{extension_settings}{$id}
Branch: 1 branch
BranchTrueFalseTotal
unless @args 0 0 0
1331 unless @args;
1332  
1333 0 ▶ croak 'extension_setting() accepts at most one value'
Branch: 1 branch
BranchTrueFalseTotal
unless @args == 1 0 0 0
1334 unless @args == 1;
1335 croak 'extension SETTINGS cannot change after start()'
1336 0 ▶ if $self->{started};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"started"} 0 0 0
1337  
1338 0 my $value = _normalize_http3_varint(
1339 $args[0],
1340 "extension setting $id value",
1341 );
1342  
1343 0 $self->{extension_settings}{$id} = $value;
1344 0 return $self;
1345 }
1346  
1347 2 ▶sub peer_extension_settings {
Subroutine peer_extension_settings: called CC=2 SCAR=7.0
Pod undocumented
1348 2 my ($self, @args) = @_;
1349 2 ▶ croak 'peer_extension_settings() does not accept arguments' if @args;
Branch: 1 branch
BranchTrueFalseTotal
if @args 0 2 2
1350 2 return { %{ $self->{peer_extension_settings} } };
1351 }
1352  
1353 3 ▶sub peer_extension_setting {
Subroutine peer_extension_setting: called CC=2 SCAR=7.0
Pod undocumented
1354 3 my ($self, $id, @args) = @_;
1355 3 ▶ croak 'peer_extension_setting() accepts one setting identifier'
Branch: 1 branch
BranchTrueFalseTotal
if @args 0 3 3
1356 if @args;
1357  
1358 3 $id = _normalize_http3_varint(
1359 $id,
1360 'peer extension setting identifier',
1361 );
1362  
1363 3 return $self->{peer_extension_settings}{$id};
1364 }
1365  
1366 25 ▶sub peer_settings_received {
Subroutine peer_settings_received: called CC=3 SCAR=11.1
Pod undocumented
1367 25 my ($self, @args) = @_;
1368 25 ▶ croak 'peer_settings_received() does not accept arguments' if @args;
Branch: 1 branch
BranchTrueFalseTotal
if @args 0 25 25
1369 25 ▶ return $self->{peer_settings_received} ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$self->{'peer_settings_received'} ? : 9 16 25
1370 }
1371  
1372 9 ▶sub peer_origins {
Subroutine peer_origins: called CC=3 SCAR=11.0
Pod undocumented
1373 9 my ($self, @args) = @_;
1374 9 ▶ croak 'peer_origins() does not accept arguments' if @args;
Branch: 1 branch
BranchTrueFalseTotal
if @args 0 9 9
1375  
1376 9 ▶ return undef unless defined $self->{peer_origins};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->{"peer_origins"} 5 4 9
1377 4 return [ @{ $self->{peer_origins} } ];
1378 }
1379  
1380 1 ▶sub extended_connect_enabled {
Subroutine extended_connect_enabled: called CC=3 SCAR=11.7
Pod undocumented
1381 1 my ($self, @args) = @_;
1382 1 ▶ croak 'extended_connect_enabled() does not accept arguments' if @args;
Branch: 1 branch
BranchTrueFalseTotal
if @args 0 1 1
1383 1 ▶ return $self->{enable_extended_connect} ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$self->{'enable_extended_connect'} ? : 1 0 1
1384 }
1385  
1386 3 ▶sub peer_extended_connect_enabled {
Subroutine peer_extended_connect_enabled: called CC=3 SCAR=11.1
Pod undocumented
1387 3 my ($self, @args) = @_;
1388 3 ▶ croak 'peer_extended_connect_enabled() does not accept arguments'
Branch: 1 branch
BranchTrueFalseTotal
if @args 0 3 3
1389 if @args;
1390 3 ▶ return $self->{peer_enable_connect_protocol} ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$self->{'peer_enable_connect_protocol'} ? : 2 1 3
1391 }
1392  
1393 2 ▶sub http_datagrams_enabled {
Subroutine http_datagrams_enabled: called CC=3 SCAR=11.7
Pod undocumented
1394 2 my ($self, @args) = @_;
1395 2 ▶ croak 'http_datagrams_enabled() does not accept arguments' if @args;
Branch: 1 branch
BranchTrueFalseTotal
if @args 0 2 2
1396 2 ▶ return $self->{enable_http_datagrams} ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$self->{'enable_http_datagrams'} ? : 2 0 2
1397 }
1398  
1399 3 ▶sub peer_http_datagrams_enabled {
Subroutine peer_http_datagrams_enabled: called CC=3 SCAR=11.7
Pod undocumented
1400 3 my ($self, @args) = @_;
1401 3 ▶ croak 'peer_http_datagrams_enabled() does not accept arguments' if @args;
Branch: 1 branch
BranchTrueFalseTotal
if @args 0 3 3
1402 3 ▶ return $self->{peer_h3_datagram} ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$self->{'peer_h3_datagram'} ? : 3 0 3
1403 }
1404  
1405 20 ▶sub can_send_http_datagrams {
Subroutine can_send_http_datagrams: called CC=6 SCAR=19.6
Pod undocumented
1406 20 my ($self, @args) = @_;
1407 20 ▶ croak 'can_send_http_datagrams() does not accept arguments' if @args;
Branch: 1 branch
BranchTrueFalseTotal
if @args 0 20 20
1408  
1409 20 ▶ return 0 unless $self->{enable_http_datagrams};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"enable_http_datagrams"} 0 20 20
1410 20 ▶ return 0 unless $self->{peer_settings_initialized};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"peer_settings_initialized"} 0 20 20
1411 20 ▶ return 0 unless $self->{peer_h3_datagram};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"peer_h3_datagram"} 0 20 20
1412  
1413 20 ▶ return $self->{quic}->can_send_datagram ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$self->{'quic'}->can_send_datagram ? : 20 0 20
1414 }
1415  
1416 2 ▶sub can_receive_http_datagrams {
Subroutine can_receive_http_datagrams: called CC=6 SCAR=19.6
Pod undocumented
1417 2 my ($self, @args) = @_;
1418 2 ▶ croak 'can_receive_http_datagrams() does not accept arguments' if @args;
Branch: 1 branch
BranchTrueFalseTotal
if @args 0 2 2
1419  
1420 2 ▶ return 0 unless $self->{enable_http_datagrams};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"enable_http_datagrams"} 0 2 2
1421 2 ▶ return 0 unless $self->{peer_settings_initialized};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"peer_settings_initialized"} 0 2 2
1422 2 ▶ return 0 unless $self->{peer_h3_datagram};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"peer_h3_datagram"} 0 2 2
1423  
1424 2 ▶ return $self->{quic}->can_receive_datagram ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$self->{'quic'}->can_receive_datagram ? : 2 0 2
1425 }
1426  
1427 6 ▶sub datagram_receive_drops {
Subroutine datagram_receive_drops: called CC=2 SCAR=7.1
Pod undocumented
1428 6 my ($self, @args) = @_;
1429 6 ▶ croak 'datagram_receive_drops() does not accept arguments' if @args;
Branch: 1 branch
BranchTrueFalseTotal
if @args 0 6 6
1430 6 return 0 + $self->{datagram_receive_drops};
1431 }
1432  
1433 0 ▶sub extension_stream_handler {
Subroutine extension_stream_handler: not called CC=5 SCAR=34.0
Pod undocumented
1434 0 my ($self, $type, @args) = @_;
1435  
1436 0 $type = _normalize_http3_varint(
1437 $type,
1438 'extension stream type',
1439 );
1440  
1441 0 _assert_extension_stream_type($type);
1442  
1443 0 ▶ return $self->{extension_stream_handlers}{$type}
Branch: 1 branch
BranchTrueFalseTotal
unless @args 0 0 0
1444 unless @args;
1445  
1446 0 ▶ croak 'extension_stream_handler() accepts at most one callback'
Branch: 1 branch
BranchTrueFalseTotal
unless @args == 1 0 0 0
1447 unless @args == 1;
1448 croak 'extension stream handlers cannot change after start()'
1449 0 ▶ if $self->{started};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"started"} 0 0 0
1450 0 ▶ croak 'extension stream handler must be a code reference'
Branch: 1 branch
BranchTrueFalseTotal
unless ref $args[0] eq "CODE" 0 0 0
1451 unless ref($args[0]) eq 'CODE';
1452  
1453 0 $self->{extension_stream_handlers}{$type} = $args[0];
1454 0 return $self;
1455 }
1456  
1457 5 ▶sub open_extension_stream {
Subroutine open_extension_stream: called CC=4 SCAR=14.0
Pod undocumented
1458 5 my ($self, $type) = @_;
1459  
1460 croak 'HTTP/3 connection has not been started'
1461 5 ▶ unless $self->{started};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"started"} 0 5 5
1462 croak 'HTTP/3 connection has failed'
1463 5 ▶ if $self->{failed};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"failed"} 0 5 5
1464  
1465 5 $type = _normalize_http3_varint(
1466 $type,
1467 'extension stream type',
1468 );
1469  
1470 5 _assert_extension_stream_type($type);
1471  
1472 3 my $stream = $self->{quic}->open_uni_stream;
1473 3 ▶ return unless defined $stream;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $stream 0 3 3
1474  
1475 3 my $header = _encode_http3_varint($type);
1476 3 $stream->send($header);
1477  
1478 3 require Unblock::HTTP3::Extension::Stream;
1479  
1480 3 my $extension = Unblock::HTTP3::Extension::Stream->_new(
1481 connection => $self,
1482 stream => $stream,
1483 type => $type,
1484 header_length => length($header),
1485 incoming => 0,
1486 );
1487  
1488 3 my $id = $stream->id;
1489 3 $self->{streams}{$id} = $stream;
1490 3 $self->{extension_stream_objects}{$id} = $extension;
1491  
1492 3 return $extension;
1493 }
1494  
1495 2 ▶sub receive_body_mode {
Subroutine receive_body_mode: called CC=7 SCAR=22.7
Pod undocumented
1496 2 my ($self, @args) = @_;
1497 2 ▶ return $self->{receive_body_mode} unless @args;
Branch: 1 branch
BranchTrueFalseTotal
unless @args 0 2 2
1498  
1499 2 ▶ croak 'receive_body_mode() accepts at most one value'
Branch: 1 branch
BranchTrueFalseTotal
unless @args == 1 0 2 2
1500 unless @args == 1;
1501 2 ▶ croak 'receive_body_mode must be buffered or stream'
Branch: 1 branch
BranchTrueFalseTotal
if not defined $args[0] or ref $args[0] or $args[0] ne "buffered" and $args[0] ne "stream" 0 2 2
Condition44%4/9
not defined $args[0] or ref $args[0] or $args[0] ne "buffered" and $args[0] ne "stream"
l!l&&r!l&&!r
002
not defined $args[0] or ref $args[0]
l!l&&r!l&&!r
002
$args[0] ne "buffered" and $args[0] ne "stream"
!ll&&!rl&&r
110
MC/DC0%0/4
not defined $args[0] or ref $args[0] or $args[0] ne "buffered" and $args[0] ne "stream"
not defined $args[0] ref $args[0] $args[0] ne "buffered" $args[0] ne "stream"
Truth table40%2/5
not(A) or B or C and D
A= not defined $args[0]B= ref $args[0]C= $args[0] ne "buffered"D= $args[0] ne "stream"
ABCDresult
1XXX1
01XX1
00111
000X0
00100
1502 if !defined($args[0])
1503 || ref($args[0])
1504 || ($args[0] ne 'buffered' && $args[0] ne 'stream');
1505  
1506 2 $self->{receive_body_mode} = $args[0];
1507 2 return $self;
1508 }
1509  
1510 11 ▶sub _fail_connection {
Subroutine _fail_connection: called CC=4 SCAR=13.9
1511 11 my ($self, $code, $message) = @_;
1512  
1513 11 ▶ return if $self->{failed};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"failed"} 0 11 11
1514  
1515 11 $self->{failed} = 1;
1516 11 $self->{error_code} = 0 + $code;
1517 11 $self->{error} = "$message";
1518  
1519 11 for my $transaction (values %{ $self->{transactions} }) {
1520 4 ▶ next if $transaction->is_terminal;
Branch: 1 branch
BranchTrueFalseTotal
if $transaction->is_terminal 2 2 4
1521 2 $transaction->_mark_error($message, $code);
1522 }
1523  
1524 11 $self->{quic}->close($code);
1525 11 return;
1526 }
1527  
1528 37 ▶sub request {
Subroutine request: called CC=66 SCAR=51.6
Pod undocumented
1529 37 my ($self, $request, %option) = @_;
1530  
1531 37 ▶ $self->_sync_early_data_status if $self->{started};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"started"} 30 7 37
1532  
1533 croak 'request() is only available on a client HTTP/3 connection'
1534 37 ▶ unless $self->{role} eq 'client';
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"role"} eq "client" 0 37 37
1535 37 ▶ croak 'request() requires the Uniform HTTP request contract'
Branch: 1 branch
BranchTrueFalseTotal
unless _request_contract($request) 0 37 37
1536 unless _request_contract($request);
1537  
1538 37 my %callbacks;
1539 37 for my $name (qw(
1540 on_informational on_response on_body on_complete on_error on_drain
1541 )) {
1542 222 ▶ next unless exists $option{$name};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $option{$name} 217 5 222
1543 5 my $callback = delete $option{$name};
1544 5 ▶ croak "request(): $name must be a code reference"
Branch: 1 branch
BranchTrueFalseTotal
if defined $callback and ref $callback ne "CODE" 0 5 5
Condition33%1/3
defined $callback and ref $callback ne "CODE"
!ll&&!rl&&r
050
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"
ABresult
0X0
100
111
1545 if defined($callback) && ref($callback) ne 'CODE';
1546 5 ▶ $callbacks{$name} = $callback if defined $callback;
Branch: 1 branch
BranchTrueFalseTotal
if defined $callback 5 0 5
1547 }
1548  
1549 37 _assert_http3_version($request, 'request()');
1550  
1551 37 ▶ my $is_connect = $request->method eq 'CONNECT' ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$request->method eq 'CONNECT' ? : 10 27 37
1552 37 ▶ my $is_extended_connect =
Branch: 1 branch
BranchTrueFalseTotal
$is_connect && defined $request->protocol ? : 7 30 37
Condition100%3/3
$is_connect and defined $request->protocol
!ll&&!rl&&r
2737
MC/DC100%2/2
$is_connect and defined $request->protocol
$is_connect defined $request->protocol
Truth table100%3/3
A and B
A= $is_connectB= defined $request->protocol
ABresult
0X0
100
111
1553 $is_connect && defined($request->protocol) ? 1 : 0;
1554 37 my $stream_body = 0;
1555 37 my $receive_body = $self->{receive_body_mode};
1556 37 my $receive_options = {};
1557 my $datagrams = exists $option{datagrams}
1558 ? delete $option{datagrams}
1559 37 ▶ : 0;
Branch: 1 branch
BranchTrueFalseTotal
exists $option{'datagrams'} ? : 3 34 37
1560 my $early_data = exists $option{early_data}
1561 ? delete $option{early_data}
1562 37 ▶ : 0;
Branch: 1 branch
BranchTrueFalseTotal
exists $option{'early_data'} ? : 2 35 37
1563  
1564 37 ▶ croak 'request(): early_data must be 0 or 1'
Branch: 1 branch
BranchTrueFalseTotal
if not defined $early_data or ref $early_data or not "$early_data" =~ /\A[01]\z/ 0 37 37
Condition33%2/6
not defined $early_data or ref $early_data or not "$early_data" =~ /\A[01]\z/
l!l&&r!l&&!r
0037
not defined $early_data or ref $early_data
l!l&&r!l&&!r
0037
MC/DC0%0/3
not defined $early_data or ref $early_data or not "$early_data" =~ /\A[01]\z/
not defined $early_data ref $early_data not "$early_data" =~ /\A[01]\z/
Truth table25%1/4
not(A) or B or not(C)
A= not defined $early_dataB= ref $early_dataC= not "$early_data" =~ /\A[01]\z/
ABCresult
1XX1
01X1
0011
0000
1565 if !defined($early_data)
1566 || ref($early_data)
1567 || "$early_data" !~ /\A[01]\z/;
1568 37 ▶ croak 'request(): datagrams must be 0 or 1'
Branch: 1 branch
BranchTrueFalseTotal
if not defined $datagrams or ref $datagrams or not "$datagrams" =~ /\A[01]\z/ 0 37 37
Condition33%2/6
not defined $datagrams or ref $datagrams or not "$datagrams" =~ /\A[01]\z/
l!l&&r!l&&!r
0037
not defined $datagrams or ref $datagrams
l!l&&r!l&&!r
0037
MC/DC0%0/3
not defined $datagrams or ref $datagrams or not "$datagrams" =~ /\A[01]\z/
not defined $datagrams ref $datagrams not "$datagrams" =~ /\A[01]\z/
Truth table25%1/4
not(A) or B or not(C)
A= not defined $datagramsB= ref $datagramsC= not "$datagrams" =~ /\A[01]\z/
ABCresult
1XX1
01X1
0011
0000
1569 if !defined($datagrams)
1570 || ref($datagrams)
1571 || "$datagrams" !~ /\A[01]\z/;
1572  
1573 37 ▶ if ($is_connect) {
Branch: 1 branch
BranchTrueFalseTotal
if ($is_connect) 10 27 37
1574 10 ▶ if ($is_extended_connect) {
Branch: 1 branch
BranchTrueFalseTotal
if ($is_extended_connect) { } 7 3 10
1575 croak 'request(): peer did not enable Extended CONNECT'
1576 7 ▶ unless $self->{peer_enable_connect_protocol};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"peer_enable_connect_protocol"} 1 6 7
1577 6 ▶ croak 'request(): Extended CONNECT requires scheme'
Branch: 1 branch
BranchTrueFalseTotal
unless defined $request->scheme 0 6 6
1578 unless defined $request->scheme;
1579 6 ▶ croak 'request(): Extended CONNECT requires authority'
Branch: 1 branch
BranchTrueFalseTotal
unless defined $request->authority 0 6 6
1580 unless defined $request->authority;
1581 } else {
1582 3 ▶ croak 'request(): CONNECT requires authority'
Branch: 1 branch
BranchTrueFalseTotal
unless defined $request->authority 0 3 3
1583 unless defined $request->authority;
1584 3 ▶ croak 'request(): CONNECT target must match authority'
Branch: 1 branch
BranchTrueFalseTotal
unless _authority_equal($request->target, $request->authority) 0 3 3
1585 unless _authority_equal(
1586 $request->target,
1587 $request->authority,
1588 );
1589 3 ▶ croak 'request(): CONNECT must not have scheme'
Branch: 1 branch
BranchTrueFalseTotal
if defined $request->scheme 0 3 3
1590 if defined $request->scheme;
1591 }
1592  
1593 9 ▶ croak 'request(): CONNECT cannot use a buffered request body'
Branch: 1 branch
BranchTrueFalseTotal
if $request->has_buffered_body 0 9 9
1594 if $request->has_buffered_body;
1595 9 ▶ croak 'request(): CONNECT cannot use request trailers'
Branch: 1 branch
BranchTrueFalseTotal
if $request->trailer_count 0 9 9
1596 if $request->trailer_count;
1597  
1598 9 $receive_body = 'stream';
1599 9 $stream_body = 1;
1600 }
1601  
1602 36 ▶ if (exists $option{stream_body}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $option{"stream_body"}) 6 30 36
1603 6 my $configured = delete $option{stream_body};
1604  
1605 6 ▶ croak 'request(): stream_body must be zero or one'
Branch: 1 branch
BranchTrueFalseTotal
if not defined $configured or ref $configured or not "$configured" =~ /\A[01]\z/ 1 5 6
Condition66%4/6
not defined $configured or ref $configured or not "$configured" =~ /\A[01]\z/
l!l&&r!l&&!r
105
not defined $configured or ref $configured
l!l&&r!l&&!r
015
MC/DC33%1/3
not defined $configured or ref $configured or not "$configured" =~ /\A[01]\z/
not defined $configured ref $configured not "$configured" =~ /\A[01]\z/
Truth table50%2/4
not(A) or B or not(C)
A= not defined $configuredB= ref $configuredC= not "$configured" =~ /\A[01]\z/
ABCresult
1XX1
01X1
0011
0000
1606 if !defined($configured)
1607 || ref($configured)
1608 || "$configured" !~ /\A[01]\z/;
1609  
1610 5 ▶ $stream_body = $configured ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$configured ? : 5 0 5
1611  
1612 5 ▶ croak 'request(): CONNECT requires stream_body => 1'
Branch: 1 branch
BranchTrueFalseTotal
if $is_connect and not $stream_body 0 5 5
Condition33%1/3
$is_connect and not $stream_body
!ll&&!rl&&r
500
MC/DC0%0/2
$is_connect and not $stream_body
$is_connect not $stream_body
Truth table33%1/3
A and not(B)
A= $is_connectB= not $stream_body
ABresult
0X0
100
111
1613 if $is_connect && !$stream_body;
1614 5 ▶ croak 'request(): stream_body cannot be combined with a buffered body'
Branch: 1 branch
BranchTrueFalseTotal
if $stream_body and $request->has_buffered_body 0 5 5
Condition33%1/3
$stream_body and $request->has_buffered_body
!ll&&!rl&&r
050
MC/DC0%0/2
$stream_body and $request->has_buffered_body
$stream_body $request->has_buffered_body
Truth table33%1/3
A and B
A= $stream_bodyB= $request->has_buffered_body
ABresult
0X0
100
111
1615 if $stream_body && $request->has_buffered_body;
1616 }
1617  
1618 $receive_body = 'stream'
1619 35 ▶ if defined $callbacks{on_body};
Branch: 1 branch
BranchTrueFalseTotal
if defined $callbacks{"on_body"} 1 34 35
1620  
1621 croak 'request(): on_drain requires stream_body'
1622 35 ▶ if defined($callbacks{on_drain}) && !$stream_body;
Branch: 1 branch
BranchTrueFalseTotal
if defined $callbacks{"on_drain"} and not $stream_body 0 35 35
Condition33%1/3
defined $callbacks{"on_drain"} and not $stream_body
!ll&&!rl&&r
3500
MC/DC0%0/2
defined $callbacks{"on_drain"} and not $stream_body
defined $callbacks{"on_drain"} not $stream_body
Truth table33%1/3
A and not(B)
A= defined $callbacks{"on_drain"}B= not $stream_body
ABresult
0X0
100
111
1623  
1624 35 ▶ if (exists $option{receive_body}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $option{"receive_body"}) 1 34 35
1625 1 my $value = delete $option{receive_body};
1626  
1627 1 ▶ if (ref($value) eq 'HASH') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $value eq 'HASH') { } 1 0 1
1628 1 $receive_body = 'stream';
1629 1 $receive_options = { %$value };
1630 } else {
1631 0 ▶ croak 'request(): receive_body must be buffered, stream, or a hash reference'
Branch: 1 branch
BranchTrueFalseTotal
if not defined $value or ref $value or $value ne "buffered" and $value ne "stream" 0 0 0
Condition0%0/9
not defined $value or ref $value or $value ne "buffered" and $value ne "stream"
l!l&&r!l&&!r
000
not defined $value or ref $value
l!l&&r!l&&!r
000
$value ne "buffered" and $value ne "stream"
!ll&&!rl&&r
000
MC/DC0%0/4
not defined $value or ref $value or $value ne "buffered" and $value ne "stream"
not defined $value ref $value $value ne "buffered" $value ne "stream"
Truth table0%0/5
not(A) or B or C and D
A= not defined $valueB= ref $valueC= $value ne "buffered"D= $value ne "stream"
ABCDresult
1XXX1
01XX1
00111
000X0
00100
1632 if !defined($value)
1633 || ref($value)
1634 || ($value ne 'buffered' && $value ne 'stream');
1635 0 $receive_body = $value;
1636 }
1637 }
1638  
1639 35 ▶ croak 'request(): CONNECT response body must use streaming receive mode'
Branch: 1 branch
BranchTrueFalseTotal
if $is_connect and $receive_body ne "stream" 0 35 35
Condition66%2/3
$is_connect and $receive_body ne "stream"
!ll&&!rl&&r
2690
MC/DC0%0/2
$is_connect and $receive_body ne "stream"
$is_connect $receive_body ne "stream"
Truth table66%2/3
A and B
A= $is_connectB= $receive_body ne "stream"
ABresult
0X0
100
111
1640 if $is_connect && $receive_body ne 'stream';
1641  
1642 35 ▶ croak 'request(): unknown options: ' . join(', ', sort keys %option)
Branch: 1 branch
BranchTrueFalseTotal
if %option 0 35 35
1643 if %option;
1644  
1645 35 $self->_assert_request_semantics(
1646 $request,
1647 'request()',
1648 );
1649 35 ▶ my $request_streaming = $stream_body ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$stream_body ? : 14 21 35
1650  
1651 35 $self->_assert_request_content_length(
1652 $request,
1653 'request()',
1654 $request_streaming,
1655 );
1656  
1657 29 ▶ my $sending_early = !$self->{quic}->ready ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
!$self->{'quic'}->ready ? : 2 27 29
1658  
1659 29 ▶ if ($sending_early) {
Branch: 1 branch
BranchTrueFalseTotal
if ($sending_early) 2 27 29
1660 2 ▶ croak 'request(): early_data => 1 is required before QUIC handshake completion'
Branch: 1 branch
BranchTrueFalseTotal
unless $early_data 0 2 2
1661 unless $early_data;
1662 croak 'request(): HTTP/3 was not started for 0-RTT'
1663 2 ▶ unless $self->{early_data_started};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"early_data_started"} 0 2 2
1664 croak 'request(): QUIC 0-RTT is not pending'
1665 2 ▶ unless $self->{quic}->early_data_status eq 'pending';
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"quic"}->early_data_status eq "pending" 0 2 2
1666 croak 'request(): remembered peer HTTP/3 settings are required for 0-RTT'
1667 2 ▶ unless $self->{peer_settings_initialized};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"peer_settings_initialized"} 0 2 2
1668 }
1669  
1670 29 my $stream_id = $self->_submit_request(
1671 $request,
1672 $request_streaming,
1673 );
1674 28 ▶ return unless defined $stream_id;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $stream_id 0 28 28
1675  
1676 28 ▶ $request->mark_incomplete if $request_streaming;
Branch: 1 branch
BranchTrueFalseTotal
if $request_streaming 13 15 28
1677  
1678 28 my $transaction = Unblock::HTTP3::Transaction->_new(
1679 connection => $self,
1680 stream_id => $stream_id,
1681 request => $request,
1682 request_streaming => $request_streaming,
1683 early_data => $sending_early,
1684 callbacks => \%callbacks,
1685 );
1686  
1687 28 ▶ $transaction->_enable_datagrams if $datagrams;
Branch: 1 branch
BranchTrueFalseTotal
if $datagrams 3 25 28
1688  
1689 28 ▶ if ($receive_body eq 'stream' && defined $callbacks{on_body}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($receive_body eq "stream" and defined $callbacks{"on_body"}) 1 27 28
Condition100%3/3
$receive_body eq "stream" and defined $callbacks{"on_body"}
!ll&&!rl&&r
1891
MC/DC100%2/2
$receive_body eq "stream" and defined $callbacks{"on_body"}
$receive_body eq "stream" defined $callbacks{"on_body"}
Truth table100%3/3
A and B
A= $receive_body eq "stream"B= defined $callbacks{"on_body"}
ABresult
0X0
100
111
1690 croak 'request(): on_body cannot be combined with receive_body on_data'
1691 1 ▶ if exists $receive_options->{on_data};
Branch: 1 branch
BranchTrueFalseTotal
if exists $receive_options->{"on_data"} 0 1 1
1692  
1693 1 my %common_receive = %$receive_options;
1694 2 ▶ $common_receive{on_data} = sub {
Subroutine __ANON__: called CC=2 SCAR=7.0
1695 2 my ($reader, $bytes) = @_;
1696 2 my $response = $transaction->response;
1697 2 my $result = $transaction->_invoke(
1698 'on_body',
1699 $response,
1700 $bytes,
1701 );
1702 2 ▶ die $result unless $result eq '1';
Branch: 1 branch
BranchTrueFalseTotal
unless $result eq 1 0 2 2
1703 1 };
1704 1 $receive_options = \%common_receive;
1705 }
1706  
1707 $transaction->_configure_receive_body(
1708 28 'response',
1709 $receive_body,
1710 $receive_options,
1711 );
1712  
1713 28 $self->{transactions}{$stream_id} = $transaction;
1714  
1715 28 ▶ if ($stream_body && defined $callbacks{on_drain}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($stream_body and defined $callbacks{"on_drain"}) 0 28 28
Condition66%2/3
$stream_body and defined $callbacks{"on_drain"}
!ll&&!rl&&r
15130
MC/DC0%0/2
$stream_body and defined $callbacks{"on_drain"}
$stream_body defined $callbacks{"on_drain"}
Truth table66%2/3
A and B
A= $stream_bodyB= defined $callbacks{"on_drain"}
ABresult
0X0
100
111
1716 $transaction->request_body(
1717 0 ▶ on_drain => sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
1718 0 my ($body) = @_;
1719 0 my $result = $transaction->_invoke('on_drain');
1720 0 ▶ die $result unless $result eq '1';
Branch: 1 branch
BranchTrueFalseTotal
unless $result eq 1 0 0 0
1721 },
1722 0 );
1723 }
1724  
1725 28 $self->_maybe_complete_transaction($stream_id);
1726  
1727 28 return $transaction;
1728 }
1729  
1730 99 ▶sub next_transaction {
Subroutine next_transaction: called CC=4 SCAR=15.2
Pod undocumented
1731 99 my ($self, @args) = @_;
1732  
1733 99 ▶ croak 'next_transaction() does not accept arguments' if @args;
Branch: 1 branch
BranchTrueFalseTotal
if @args 0 99 99
1734 99 ▶ $self->_service if $self->{started} && !$self->{failed};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"started"} and not $self->{"failed"} 99 0 99
Condition33%1/3
$self->{"started"} and not $self->{"failed"}
!ll&&!rl&&r
0099
MC/DC0%0/2
$self->{"started"} and not $self->{"failed"}
$self->{"started"} not $self->{"failed"}
Truth table33%1/3
A and not(B)
A= $self->{"started"}B= not $self->{"failed"}
ABresult
0X0
100
111
1735 99 return shift @{ $self->{ready_transactions} };
1736 }
1737  
1738 3 ▶sub next_informational {
Subroutine next_informational: called CC=4 SCAR=15.2
Pod undocumented
1739 3 my ($self, @args) = @_;
1740  
1741 3 ▶ croak 'next_informational() does not accept arguments' if @args;
Branch: 1 branch
BranchTrueFalseTotal
if @args 0 3 3
1742 3 ▶ $self->_service if $self->{started} && !$self->{failed};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"started"} and not $self->{"failed"} 3 0 3
Condition33%1/3
$self->{"started"} and not $self->{"failed"}
!ll&&!rl&&r
003
MC/DC0%0/2
$self->{"started"} and not $self->{"failed"}
$self->{"started"} not $self->{"failed"}
Truth table33%1/3
A and not(B)
A= $self->{"started"}B= not $self->{"failed"}
ABresult
0X0
100
111
1743 3 return shift @{ $self->{ready_informational} };
1744 }
1745  
1746 67 ▶sub _request_contract {
Subroutine _request_contract: called CC=4 SCAR=14.3
1747 67 my ($request) = @_;
1748 67 ▶ return unless blessed($request);
Branch: 1 branch
BranchTrueFalseTotal
unless builtin::blessed($request) 0 67 67
1749  
1750 67 for my $method (qw(
1751 method target scheme authority protocol version
1752 header_count header_name header_value
1753 trailer_count trailer_name trailer_value
1754 has_buffered_body body
1755 )) {
1756 938 ▶ return unless $request->can($method);
Branch: 1 branch
BranchTrueFalseTotal
unless $request->can($method) 0 938 938
1757 }
1758  
1759 67 return 1;
1760 }
1761  
1762 56 ▶sub _response_contract {
Subroutine _response_contract: called CC=4 SCAR=14.3
1763 56 my ($response) = @_;
1764 56 ▶ return unless blessed($response);
Branch: 1 branch
BranchTrueFalseTotal
unless builtin::blessed($response) 0 56 56
1765  
1766 56 for my $method (qw(
1767 status version
1768 header_count header_name header_value
1769 trailer_count trailer_name trailer_value
1770 has_buffered_body body
1771 )) {
1772 560 ▶ return unless $response->can($method);
Branch: 1 branch
BranchTrueFalseTotal
unless $response->can($method) 0 560 560
1773 }
1774  
1775 56 return 1;
1776 }
1777  
1778 152 ▶sub _message_header_values {
Subroutine _message_header_values: called CC=3 SCAR=11.0
1779 152 my ($message, $wanted) = @_;
1780  
1781 152 $wanted = lc $wanted;
1782 152 my @values;
1783  
1784 152 for my $index (0 .. $message->header_count - 1) {
1785 70 my $name = lc $message->header_name($index);
1786 70 ▶ push @values, $message->header_value($index)
Branch: 1 branch
BranchTrueFalseTotal
if $name eq $wanted 16 54 70
1787 if $name eq $wanted;
1788 }
1789  
1790 152 return \@values;
1791 }
1792  
1793 2 ▶sub _portable_headers {
Subroutine _portable_headers: called CC=2 SCAR=9.2
1794 2 my ($message, $context) = @_;
1795 2 my @fields;
1796  
1797 2 for my $index (0 .. $message->header_count - 1) {
1798 0 my $name = lc $message->header_name($index);
1799 0 my $value = $message->header_value($index);
1800 0 _validate_wire_field($context, $name, $value);
1801 0 push @fields, [ $name, $value ];
1802 }
1803  
1804 2 return \@fields;
1805 }
1806  
1807 0 ▶sub _portable_trailers {
Subroutine _portable_trailers: not called CC=2 SCAR=17.9
1808 0 my ($message) = @_;
1809 0 my @fields;
1810  
1811 0 for my $index (0 .. $message->trailer_count - 1) {
1812 0 my $name = lc $message->trailer_name($index);
1813 0 my $value = $message->trailer_value($index);
1814 0 push @fields, @{ _wire_trailers([ [ $name, $value ] ]) };
1815 }
1816  
1817 0 return \@fields;
1818 }
1819  
1820 1 ▶sub _portable_request_fields {
Subroutine _portable_request_fields: called CC=4 SCAR=14.7
1821 1 my ($request) = @_;
1822  
1823 1 my @fields = ([ ':method', $request->method ]);
1824 1 my $method = $request->method;
1825 1 my $protocol = $request->protocol;
1826  
1827 1 ▶ if ($method eq 'CONNECT' && !defined $protocol) {
Branch: 1 branch
BranchTrueFalseTotal
if ($method eq 'CONNECT' and not defined $protocol) { } 0 1 1
Condition33%1/3
$method eq "CONNECT" and not defined $protocol
!ll&&!rl&&r
100
MC/DC0%0/2
$method eq "CONNECT" and not defined $protocol
$method eq "CONNECT" not defined $protocol
Truth table33%1/3
A and not(B)
A= $method eq "CONNECT"B= not defined $protocol
ABresult
0X0
100
111
1828 0 push @fields, [ ':authority', $request->authority ];
1829 } else {
1830 1 ▶ push @fields, [ ':protocol', $protocol ]
Branch: 1 branch
BranchTrueFalseTotal
if defined $protocol 0 1 1
1831 if defined $protocol;
1832 1 push @fields,
1833 [ ':scheme', $request->scheme ],
1834 [ ':authority', $request->authority ],
1835 [ ':path', $request->target ];
1836 }
1837  
1838 1 push @fields, @{ _portable_headers($request, 'request') };
1839 1 return \@fields;
1840 }
1841  
1842 1 ▶sub _portable_response_fields {
Subroutine _portable_response_fields: called CC=1 SCAR=0.0
1843 1 my ($response) = @_;
1844  
1845 1 my @fields = ([ ':status', '' . $response->status ]);
1846 1 push @fields, @{ _portable_headers($response, 'response') };
1847 1 return \@fields;
1848 }
1849  
1850 31 ▶sub _assert_response_contract {
Subroutine _assert_response_contract: called CC=2 SCAR=7.1
1851 31 my ($self, $response, $operation) = @_;
1852 31 ▶ croak "$operation: requires the Uniform HTTP response contract"
Branch: 1 branch
BranchTrueFalseTotal
unless _response_contract($response) 0 31 31
1853 unless _response_contract($response);
1854 31 return $response;
1855 }
1856  
1857 67 ▶sub _assert_http3_version {
Subroutine _assert_http3_version: called CC=3 SCAR=11.0
1858 67 my ($message, $operation) = @_;
1859  
1860 67 my $version = $message->version;
1861 67 ▶ return unless defined $version;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $version 49 18 67
1862  
1863 18 ▶ croak "$operation: explicit message version must be 3 for HTTP/3"
Branch: 1 branch
BranchTrueFalseTotal
unless "$version" eq 3 1 17 18
1864 unless "$version" eq '3';
1865  
1866 17 return;
1867 }
1868  
1869 98 ▶sub _declared_content_length {
Subroutine _declared_content_length: called CC=4 SCAR=13.9
1870 98 my ($message, $operation) = @_;
1871  
1872 98 my $values = _message_header_values($message, 'content-length');
1873 98 ▶ return unless @$values;
Branch: 1 branch
BranchTrueFalseTotal
unless @$values 83 15 98
1874  
1875 15 ▶ croak "$operation: multiple Content-Length fields are not allowed"
Branch: 1 branch
BranchTrueFalseTotal
unless @$values == 1 1 14 15
1876 unless @$values == 1;
1877  
1878 14 my $value = $values->[0];
1879  
1880 14 ▶ croak "$operation: Content-Length must be a decimal non-negative integer"
Branch: 1 branch
BranchTrueFalseTotal
unless $value =~ /\A[0-9]+\z/ 3 11 14
1881 unless $value =~ /\A[0-9]+\z/;
1882  
1883 11 $value =~ s/\A0+(?=[0-9])//;
1884  
1885 11 return $value;
1886 }
1887  
1888 3 ▶sub _content_length_matches {
Subroutine _content_length_matches: called CC=2 SCAR=7.2
1889 3 my ($declared, $actual) = @_;
1890 3 ▶ return $declared eq "$actual" ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$declared eq "$actual" ? : 0 3 3
1891 }
1892  
1893 3 ▶sub _content_length_is_less_than {
Subroutine _content_length_is_less_than: called CC=4 SCAR=14.1
1894 3 my ($declared, $actual) = @_;
1895  
1896 3 my $actual_text = "$actual";
1897  
1898 3 ▶ return 1 if length($declared) < length($actual_text);
Branch: 1 branch
BranchTrueFalseTotal
if length $declared < length $actual_text 0 3 3
1899 3 ▶ return 0 if length($declared) > length($actual_text);
Branch: 1 branch
BranchTrueFalseTotal
if length $declared > length $actual_text 0 3 3
1900  
1901 3 ▶ return $declared lt $actual_text ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$declared lt $actual_text ? : 1 2 3
1902 }
1903  
1904 55 ▶sub _assert_request_content_length {
Subroutine _assert_request_content_length: called CC=7 SCAR=20.8
1905 55 my ($self, $request, $operation, $streaming) = @_;
1906  
1907 55 my $declared = _declared_content_length($request, $operation);
1908 51 ▶ return unless defined $declared;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $declared 49 2 51
1909  
1910 2 ▶ if ($request->method eq 'CONNECT') {
Branch: 1 branch
BranchTrueFalseTotal
if ($request->method eq "CONNECT") 1 1 2
1911 1 ▶ croak "$operation: CONNECT request Content-Length must be 0"
Branch: 1 branch
BranchTrueFalseTotal
unless $declared eq 0 1 0 1
1912 unless $declared eq '0';
1913 0 return $declared;
1914 }
1915  
1916 1 ▶ return $declared if $streaming;
Branch: 1 branch
BranchTrueFalseTotal
if $streaming 0 1 1
1917  
1918 1 ▶ my $actual = $request->has_buffered_body
Branch: 1 branch
BranchTrueFalseTotal
$request->has_buffered_body ? : 1 0 1
1919 ? length($request->body)
1920 : 0;
1921  
1922 1 ▶ croak "$operation: Content-Length $declared does not match $actual body bytes"
Branch: 1 branch
BranchTrueFalseTotal
unless _content_length_matches($declared, $actual) 1 0 1
1923 unless _content_length_matches($declared, $actual);
1924  
1925 0 return $declared;
1926 }
1927  
1928 43 ▶sub _assert_response_content_length {
Subroutine _assert_response_content_length: called CC=15 SCAR=28.4
1929 43 my ($self, $transaction, $response, $operation) = @_;
1930  
1931 43 my $declared = _declared_content_length($response, $operation);
1932 43 ▶ return unless defined $declared;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $declared 34 9 43
1933  
1934 9 my $method = $transaction->request->method;
1935 9 my $status = $response->status;
1936  
1937 9 ▶ croak "$operation: Content-Length is not allowed on informational responses"
Branch: 1 branch
BranchTrueFalseTotal
if $status >= 100 and $status < 200 0 9 9
Condition33%1/3
$status >= 100 and $status < 200
!ll&&!rl&&r
090
MC/DC0%0/2
$status >= 100 and $status < 200
$status >= 100 $status < 200
Truth table33%1/3
A and B
A= $status >= 100B= $status < 200
ABresult
0X0
100
111
1938 if $status >= 100 && $status < 200;
1939 9 ▶ croak "$operation: Content-Length is not allowed on a 204 response"
Branch: 1 branch
BranchTrueFalseTotal
if $status == 204 1 8 9
1940 if $status == 204;
1941 8 ▶ croak "$operation: Content-Length is not allowed on a successful CONNECT response"
Branch: 1 branch
BranchTrueFalseTotal
if $method eq "CONNECT" and $status >= 200 and $status < 300 1 7 8
Condition66%4/6
$method eq "CONNECT" and $status >= 200 and $status < 300
!ll&&!rl&&r
701
$method eq "CONNECT" and $status >= 200
!ll&&!rl&&r
701
MC/DC33%1/3
$method eq "CONNECT" and $status >= 200 and $status < 300
$method eq "CONNECT" $status >= 200 $status < 300
Truth table50%2/4
A and B and C
A= $method eq "CONNECT"B= $status >= 200C= $status < 300
ABCresult
0XX0
10X0
1100
1111
1942 if $method eq 'CONNECT' && $status >= 200 && $status < 300;
1943  
1944 7 ▶ return $declared
Branch: 1 branch
BranchTrueFalseTotal
if $method eq "HEAD" or $status == 304 2 5 7
Condition100%3/3
$method eq "HEAD" or $status == 304
l!l&&r!l&&!r
115
MC/DC100%2/2
$method eq "HEAD" or $status == 304
$method eq "HEAD" $status == 304
Truth table100%3/3
A or B
A= $method eq "HEAD"B= $status == 304
ABresult
1X1
011
000
1945 if $method eq 'HEAD' || $status == 304;
1946  
1947 5 ▶ if ($status == 205) {
Branch: 1 branch
BranchTrueFalseTotal
if ($status == 205) 1 4 5
1948 1 ▶ croak "$operation: Content-Length on a 205 response must be 0"
Branch: 1 branch
BranchTrueFalseTotal
unless $declared eq 0 1 0 1
1949 unless $declared eq '0';
1950 0 return $declared;
1951 }
1952  
1953 4 ▶ return $declared if $transaction->_response_is_streaming;
Branch: 1 branch
BranchTrueFalseTotal
if $transaction->_response_is_streaming 3 1 4
1954  
1955 1 ▶ my $actual = $response->has_buffered_body
Branch: 1 branch
BranchTrueFalseTotal
$response->has_buffered_body ? : 1 0 1
1956 ? length($response->body)
1957 : 0;
1958  
1959 1 ▶ croak "$operation: Content-Length $declared does not match $actual body bytes"
Branch: 1 branch
BranchTrueFalseTotal
unless _content_length_matches($declared, $actual) 1 0 1
1960 unless _content_length_matches($declared, $actual);
1961  
1962 0 return $declared;
1963 }
1964  
1965 38 ▶sub _assert_incremental_content_length {
Subroutine _assert_incremental_content_length: called CC=13 SCAR=26.0
1966 38 my ($self, $transaction, $kind, $message, $bytes, $final, $operation) = @_;
1967  
1968 38 my $declared;
1969  
1970 38 ▶ if ($kind eq 'request') {
Branch: 1 branch
BranchTrueFalseTotal
if ($kind eq 'request') { } 20 18 38
1971 20 $declared = $self->_assert_request_content_length(
1972 $message,
1973 $operation,
1974 );
1975  
1976 20 ▶ return if $message->method eq 'CONNECT';
Branch: 1 branch
BranchTrueFalseTotal
if $message->method eq "CONNECT" 11 9 20
1977 } else {
1978 18 $declared = $self->_assert_response_content_length(
1979 $transaction,
1980 $message,
1981 $operation,
1982 );
1983  
1984 18 my $status = $message->status;
1985 return
1986 18 ▶ if $transaction->request->method eq 'HEAD'
Branch: 1 branch
BranchTrueFalseTotal
if $transaction->request->method eq "HEAD" or $status == 304 or $transaction->request->method eq "CONNECT" and $status >= 200 and $status < 300 8 10 18
Condition58%7/12
$transaction->request->method eq "HEAD" or $status == 304 or $transaction->request->method eq "CONNECT" and $status >= 200 and $status < 300
l!l&&r!l&&!r
0810
$transaction->request->method eq "HEAD" or $status == 304
l!l&&r!l&&!r
0018
$transaction->request->method eq "CONNECT" and $status >= 200 and $status < 300
!ll&&!rl&&r
1008
$transaction->request->method eq "CONNECT" and $status >= 200
!ll&&!rl&&r
1008
MC/DC20%1/5
$transaction->request->method eq "HEAD" or $status == 304 or $transaction->request->method eq "CONNECT" and $status >= 200 and $status < 300
$transaction->request->method eq "HEAD" $status == 304 $transaction->request->method eq "CONNECT" $status >= 200 $status < 300
Truth table33%2/6
A or B or C and D and E
A= $transaction->request->method eq "HEAD"B= $status == 304C= $transaction->request->method eq "CONNECT"D= $status >= 200E= $status < 300
ABCDEresult
1XXXX1
01XXX1
001111
000XX0
0010X0
001100
1987 || $status == 304
1988 || ($transaction->request->method eq 'CONNECT'
1989 && $status >= 200 && $status < 300);
1990 }
1991  
1992 19 ▶ return unless defined $declared;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $declared 16 3 19
1993  
1994 3 my $id = $transaction->stream_id;
1995 3 ▶ my $sent = $self->{body_bytes_sent}{$id}{$kind} // 0;
Condition100%2/2
$self->{"body_bytes_sent"}{$id}{$kind} // 0
l!l
12
MC/DC100%1/1
$self->{"body_bytes_sent"}{$id}{$kind} // 0
$self->{"body_bytes_sent"}{$id}{$kind}
Truth table100%2/2
A
A= $self->{"body_bytes_sent"}{$id}{$kind}
Aresult
11
00
1996 3 my $next = $sent + length($bytes);
1997  
1998 3 ▶ croak "$operation: body exceeds Content-Length $declared"
Branch: 1 branch
BranchTrueFalseTotal
if _content_length_is_less_than($declared, $next) 1 2 3
1999 if _content_length_is_less_than($declared, $next);
2000  
2001 2 ▶ if ($final) {
Branch: 1 branch
BranchTrueFalseTotal
if ($final) 1 1 2
2002 1 ▶ croak "$operation: Content-Length $declared does not match $next body bytes"
Branch: 1 branch
BranchTrueFalseTotal
unless _content_length_matches($declared, $next) 1 0 1
2003 unless _content_length_matches($declared, $next);
2004 }
2005  
2006 1 $self->{body_bytes_sent}{$id}{$kind} = $next;
2007 1 return;
2008 }
2009  
2010 2 ▶sub _send_informational_response {
Subroutine _send_informational_response: called CC=11 SCAR=30.2
2011 2 my ($self, $transaction, $response) = @_;
2012  
2013 croak 'informational responses require a server HTTP/3 connection'
2014 2 ▶ unless $self->{role} eq 'server';
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"role"} eq "server" 0 2 2
2015 croak 'Transaction does not belong to this HTTP/3 connection'
2016 unless blessed($transaction)
2017 && $transaction->isa('Unblock::HTTP3::Transaction')
2018 && defined($self->{transactions}{ $transaction->stream_id })
2019 2 ▶ && $self->{transactions}{ $transaction->stream_id } == $transaction;
Branch: 1 branch
BranchTrueFalseTotal
unless builtin::blessed($transaction) and $transaction->isa("Unblock::HTTP3::Transaction") and defined $self->{"transactions"}{$transaction->stream_id} and $self->{"transactions"}{$transaction->stream_id} == $transaction 0 2 2
Condition33%3/9
builtin::blessed($transaction) and $transaction->isa("Unblock::HTTP3::Transaction") and defined $self->{"transactions"}{$transaction->stream_id} and $self->{"transactions"}{$transaction->stream_id} == $transaction
!ll&&!rl&&r
002
builtin::blessed($transaction) and $transaction->isa("Unblock::HTTP3::Transaction") and defined $self->{"transactions"}{$transaction->stream_id}
!ll&&!rl&&r
002
builtin::blessed($transaction) and $transaction->isa("Unblock::HTTP3::Transaction")
!ll&&!rl&&r
002
MC/DC0%0/4
builtin::blessed($transaction) and $transaction->isa("Unblock::HTTP3::Transaction") and defined $self->{"transactions"}{$transaction->stream_id} and $self->{"transactions"}{$transaction->stream_id} == $transaction
builtin::blessed($transaction) $transaction->isa("Unblock::HTTP3::Transaction") defined $self->{"transactions"}{$transaction->stream_id} $self->{"transactions"}{$transaction->stream_id} == $transaction
Truth table20%1/5
A and B and C and D
A= builtin::blessed($transaction)B= $transaction->isa("Unblock::HTTP3::Transaction")C= defined $self->{"transactions"}{$transaction->stream_id}D= $self->{"transactions"}{$transaction->stream_id} == $transaction
ABCDresult
0XXX0
10XX0
110X0
11100
11111
2020 croak 'final response has already started'
2021 2 ▶ if $self->{response_sent}{ $transaction->stream_id };
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"response_sent"}{$transaction->stream_id} 0 2 2
2022 2 _assert_http3_version($response, 'send_informational()');
2023  
2024 2 ▶ croak 'informational response status must be 100 through 199, excluding 101'
Branch: 1 branch
BranchTrueFalseTotal
unless $response->status >= 100 and $response->status <= 199 and $response->status != 101 0 2 2
Condition33%2/6
$response->status >= 100 and $response->status <= 199 and $response->status != 101
!ll&&!rl&&r
002
$response->status >= 100 and $response->status <= 199
!ll&&!rl&&r
002
MC/DC0%0/3
$response->status >= 100 and $response->status <= 199 and $response->status != 101
$response->status >= 100 $response->status <= 199 $response->status != 101
Truth table25%1/4
A and B and C
A= $response->status >= 100B= $response->status <= 199C= $response->status != 101
ABCresult
0XX0
10X0
1100
1111
2025 unless $response->status >= 100
2026 && $response->status <= 199
2027 && $response->status != 101;
2028  
2029 2 $self->_assert_response_content_length(
2030 $transaction,
2031 $response,
2032 'send_informational()',
2033 );
2034 2 _assert_capsule_protocol_response(
2035 $response,
2036 'send_informational()',
2037 );
2038  
2039 2 ▶ if (ref($response) eq 'Uniform::HTTP::Response') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $response eq 'Uniform::HTTP::Response') { } 2 0 2
2040 $self->_assert_peer_field_section_size_value(
2041 2 $self->{native}->uniform_response_field_section_size($response),
2042 'send_informational()',
2043 );
2044  
2045 $self->{native}->submit_uniform_info(
2046 2 $transaction->stream_id,
2047 $response,
2048 );
2049  
2050 2 $response->freeze;
2051 } else {
2052 0 my $fields = _portable_response_fields($response);
2053  
2054 0 $self->_assert_peer_field_section_size_value(
2055 _field_section_size($fields),
2056 'send_informational()',
2057 );
2058  
2059 $self->{native}->submit_info(
2060 0 $transaction->stream_id,
2061 $fields,
2062 );
2063 }
2064  
2065 2 $self->_drain_output;
2066 2 return $response;
2067 }
2068  
2069 3 ▶sub _capsule_protocol_response_error {
Subroutine _capsule_protocol_response_error: called CC=6 SCAR=17.9
2070 3 my ($status, $headers) = @_;
2071  
2072 3 my $present = 0;
2073  
2074 3 for my $field (@$headers) {
2075 3 my $name = lc($field->[0]);
2076 3 ▶ if ($name eq 'capsule-protocol') {
Branch: 1 branch
BranchTrueFalseTotal
if ($name eq "capsule-protocol") 2 1 3
2077 2 $present = 1;
2078 2 last;
2079 }
2080 }
2081  
2082 3 ▶ return unless $present;
Branch: 1 branch
BranchTrueFalseTotal
unless $present 1 2 3
2083 2 ▶ return if $status >= 200 && $status < 300;
Branch: 1 branch
BranchTrueFalseTotal
if $status >= 200 and $status < 300 1 1 2
Condition66%2/3
$status >= 200 and $status < 300
!ll&&!rl&&r
011
MC/DC50%1/2
$status >= 200 and $status < 300
$status >= 200 $status < 300
Truth table66%2/3
A and B
A= $status >= 200B= $status < 300
ABresult
0X0
100
111
2084  
2085 1 return 'Capsule-Protocol is only valid on a successful HTTP/3 response';
2086 }
2087  
2088 19 ▶sub _assert_capsule_protocol_response {
Subroutine _assert_capsule_protocol_response: called CC=4 SCAR=21.7
2089 19 my ($response, $operation) = @_;
2090  
2091 19 my $values = _message_header_values($response, 'capsule-protocol');
2092 19 ▶ return unless @$values;
Branch: 1 branch
BranchTrueFalseTotal
unless @$values 19 0 19
2093 0 ▶ return if $response->status >= 200 && $response->status < 300;
Branch: 1 branch
BranchTrueFalseTotal
if $response->status >= 200 and $response->status < 300 0 0 0
Condition0%0/3
$response->status >= 200 and $response->status < 300
!ll&&!rl&&r
000
MC/DC0%0/2
$response->status >= 200 and $response->status < 300
$response->status >= 200 $response->status < 300
Truth table0%0/3
A and B
A= $response->status >= 200B= $response->status < 300
ABresult
0X0
100
111
2094  
2095 0 croak "$operation: Capsule-Protocol is only valid on a successful HTTP/3 response";
2096 }
2097  
2098 53 ▶sub _response_content_forbidden_reason {
Subroutine _response_content_forbidden_reason: called CC=5 SCAR=16.1
2099 53 my ($self, $transaction, $response) = @_;
2100  
2101 53 my $method = $transaction->request->method;
2102 53 my $status = $response->status;
2103  
2104 53 ▶ return 'response to HEAD must not contain content'
Branch: 1 branch
BranchTrueFalseTotal
if $method eq "HEAD" 3 50 53
2105 if $method eq 'HEAD';
2106 50 ▶ return '204 response must not contain content'
Branch: 1 branch
BranchTrueFalseTotal
if $status == 204 7 43 50
2107 if $status == 204;
2108 43 ▶ return '205 response must not contain content'
Branch: 1 branch
BranchTrueFalseTotal
if $status == 205 2 41 43
2109 if $status == 205;
2110 41 ▶ return '304 response must not contain content'
Branch: 1 branch
BranchTrueFalseTotal
if $status == 304 2 39 41
2111 if $status == 304;
2112  
2113 39 return;
2114 }
2115  
2116 28 ▶sub _assert_response_body_allowed {
Subroutine _assert_response_body_allowed: called CC=2 SCAR=6.9
2117 28 my ($self, $transaction, $response, $operation) = @_;
2118  
2119 28 my $reason = $self->_response_content_forbidden_reason(
2120 $transaction,
2121 $response,
2122 );
2123  
2124 28 ▶ croak "$operation: $reason"
Branch: 1 branch
BranchTrueFalseTotal
if defined $reason 4 24 28
2125 if defined $reason;
2126  
2127 24 return;
2128 }
2129  
2130 25 ▶sub _assert_response_message_allowed {
Subroutine _assert_response_message_allowed: called CC=5 SCAR=16.1
2131 25 my ($self, $transaction, $response, $operation) = @_;
2132  
2133 25 my $reason = $self->_response_content_forbidden_reason(
2134 $transaction,
2135 $response,
2136 );
2137  
2138 25 ▶ return unless defined $reason;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $reason 15 10 25
2139  
2140 10 ▶ croak "$operation: $reason"
Branch: 1 branch
BranchTrueFalseTotal
if $response->has_buffered_body or $transaction->_response_is_streaming or $response->trailer_count 5 5 10
Condition83%5/6
$response->has_buffered_body or $transaction->_response_is_streaming or $response->trailer_count
l!l&&r!l&&!r
415
$response->has_buffered_body or $transaction->_response_is_streaming
l!l&&r!l&&!r
406
MC/DC66%2/3
$response->has_buffered_body or $transaction->_response_is_streaming or $response->trailer_count
$response->has_buffered_body $transaction->_response_is_streaming $response->trailer_count
Truth table75%3/4
A or B or C
A= $response->has_buffered_bodyB= $transaction->_response_is_streamingC= $response->trailer_count
ABCresult
1XX1
01X1
0011
0000
2141 if $response->has_buffered_body
2142 || $transaction->_response_is_streaming
2143 || $response->trailer_count;
2144  
2145 5 return;
2146 }
2147  
2148 26 ▶sub _respond_transaction {
Subroutine _respond_transaction: called CC=26 SCAR=39.9
2149 26 my ($self, $transaction, $response, %option) = @_;
2150  
2151 croak 'respond() requires a server HTTP/3 connection'
2152 26 ▶ unless $self->{role} eq 'server';
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"role"} eq "server" 0 26 26
2153 croak 'Transaction does not belong to this HTTP/3 connection'
2154 unless blessed($transaction)
2155 && $transaction->isa('Unblock::HTTP3::Transaction')
2156 && defined($self->{transactions}{ $transaction->stream_id })
2157 26 ▶ && $self->{transactions}{ $transaction->stream_id } == $transaction;
Branch: 1 branch
BranchTrueFalseTotal
unless builtin::blessed($transaction) and $transaction->isa("Unblock::HTTP3::Transaction") and defined $self->{"transactions"}{$transaction->stream_id} and $self->{"transactions"}{$transaction->stream_id} == $transaction 0 26 26
Condition33%3/9
builtin::blessed($transaction) and $transaction->isa("Unblock::HTTP3::Transaction") and defined $self->{"transactions"}{$transaction->stream_id} and $self->{"transactions"}{$transaction->stream_id} == $transaction
!ll&&!rl&&r
0026
builtin::blessed($transaction) and $transaction->isa("Unblock::HTTP3::Transaction") and defined $self->{"transactions"}{$transaction->stream_id}
!ll&&!rl&&r
0026
builtin::blessed($transaction) and $transaction->isa("Unblock::HTTP3::Transaction")
!ll&&!rl&&r
0026
MC/DC0%0/4
builtin::blessed($transaction) and $transaction->isa("Unblock::HTTP3::Transaction") and defined $self->{"transactions"}{$transaction->stream_id} and $self->{"transactions"}{$transaction->stream_id} == $transaction
builtin::blessed($transaction) $transaction->isa("Unblock::HTTP3::Transaction") defined $self->{"transactions"}{$transaction->stream_id} $self->{"transactions"}{$transaction->stream_id} == $transaction
Truth table20%1/5
A and B and C and D
A= builtin::blessed($transaction)B= $transaction->isa("Unblock::HTTP3::Transaction")C= defined $self->{"transactions"}{$transaction->stream_id}D= $self->{"transactions"}{$transaction->stream_id} == $transaction
ABCDresult
0XXX0
10XX0
110X0
11100
11111
2158 croak 'response has already been sent for this Transaction'
2159 26 ▶ if $self->{response_sent}{ $transaction->stream_id };
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"response_sent"}{$transaction->stream_id} 0 26 26
2160  
2161 26 $self->_assert_response_contract(
2162 $response,
2163 'respond()',
2164 );
2165  
2166 my $stream_body = exists($option{stream_body})
2167 ? delete($option{stream_body})
2168 26 ▶ : 0;
Branch: 1 branch
BranchTrueFalseTotal
exists $option{'stream_body'} ? : 2 24 26
2169 26 ▶ croak 'respond(): stream_body must be zero or one'
Branch: 1 branch
BranchTrueFalseTotal
if not defined $stream_body or ref $stream_body or not "$stream_body" =~ /\A[01]\z/ 1 25 26
Condition66%4/6
not defined $stream_body or ref $stream_body or not "$stream_body" =~ /\A[01]\z/
l!l&&r!l&&!r
1025
not defined $stream_body or ref $stream_body
l!l&&r!l&&!r
0125
MC/DC33%1/3
not defined $stream_body or ref $stream_body or not "$stream_body" =~ /\A[01]\z/
not defined $stream_body ref $stream_body not "$stream_body" =~ /\A[01]\z/
Truth table50%2/4
not(A) or B or not(C)
A= not defined $stream_bodyB= ref $stream_bodyC= not "$stream_body" =~ /\A[01]\z/
ABCresult
1XX1
01X1
0011
0000
2170 if !defined($stream_body)
2171 || ref($stream_body)
2172 || "$stream_body" !~ /\A[01]\z/;
2173 25 ▶ $stream_body = $stream_body ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$stream_body ? : 1 24 25
2174  
2175 25 my $on_drain = delete $option{on_drain};
2176 25 my $on_error = delete $option{on_error};
2177  
2178 25 ▶ croak 'respond(): on_drain must be a coderef'
Branch: 1 branch
BranchTrueFalseTotal
if defined $on_drain and ref $on_drain ne "CODE" 0 25 25
Condition33%1/3
defined $on_drain and ref $on_drain ne "CODE"
!ll&&!rl&&r
2500
MC/DC0%0/2
defined $on_drain and ref $on_drain ne "CODE"
defined $on_drain ref $on_drain ne "CODE"
Truth table33%1/3
A and B
A= defined $on_drainB= ref $on_drain ne "CODE"
ABresult
0X0
100
111
2179 if defined($on_drain) && ref($on_drain) ne 'CODE';
2180 25 ▶ croak 'respond(): on_error must be a coderef'
Branch: 1 branch
BranchTrueFalseTotal
if defined $on_error and ref $on_error ne "CODE" 0 25 25
Condition33%1/3
defined $on_error and ref $on_error ne "CODE"
!ll&&!rl&&r
2500
MC/DC0%0/2
defined $on_error and ref $on_error ne "CODE"
defined $on_error ref $on_error ne "CODE"
Truth table33%1/3
A and B
A= defined $on_errorB= ref $on_error ne "CODE"
ABresult
0X0
100
111
2181 if defined($on_error) && ref($on_error) ne 'CODE';
2182 25 ▶ croak 'respond(): unknown options: ' . join(', ', sort keys %option)
Branch: 1 branch
BranchTrueFalseTotal
if %option 0 25 25
2183 if %option;
2184 25 ▶ croak 'respond(): on_drain requires stream_body'
Branch: 1 branch
BranchTrueFalseTotal
if $on_drain and not $stream_body 0 25 25
Condition33%1/3
$on_drain and not $stream_body
!ll&&!rl&&r
2500
MC/DC0%0/2
$on_drain and not $stream_body
$on_drain not $stream_body
Truth table33%1/3
A and not(B)
A= $on_drainB= not $stream_body
ABresult
0X0
100
111
2185 if $on_drain && !$stream_body;
2186 25 ▶ croak 'respond(): stream_body cannot be combined with a buffered body'
Branch: 1 branch
BranchTrueFalseTotal
if $stream_body and $response->has_buffered_body 0 25 25
Condition66%2/3
$stream_body and $response->has_buffered_body
!ll&&!rl&&r
2410
MC/DC0%0/2
$stream_body and $response->has_buffered_body
$stream_body $response->has_buffered_body
Truth table66%2/3
A and B
A= $stream_bodyB= $response->has_buffered_body
ABresult
0X0
100
111
2187 if $stream_body && $response->has_buffered_body;
2188  
2189 25 $transaction->{response} = $response;
2190 25 $transaction->{response_body} = undef;
2191 25 $transaction->{response_streaming} = 0;
2192  
2193 25 ▶ if ($stream_body) {
Branch: 1 branch
BranchTrueFalseTotal
if ($stream_body) 1 24 25
2194 1 my %stream_option;
2195  
2196 1 ▶ if ($on_drain) {
Branch: 1 branch
BranchTrueFalseTotal
if ($on_drain) 0 1 1
2197 0 $transaction->_set_callback('on_drain', $on_drain);
2198 0 ▶ $stream_option{on_drain} = sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
2199 0 my ($body) = @_;
2200 0 my $result = $transaction->_invoke('on_drain');
2201 0 ▶ die $result unless $result eq '1';
Branch: 1 branch
BranchTrueFalseTotal
unless $result eq 1 0 0 0
2202 0 };
2203 }
2204  
2205 1 $transaction->response_body(%stream_option);
2206 }
2207  
2208 25 ▶ $transaction->_set_callback('on_error', $on_error)
Branch: 1 branch
BranchTrueFalseTotal
if $on_error 0 25 25
2209 if $on_error;
2210  
2211 25 _assert_http3_version($response, 'respond()');
2212  
2213 25 $self->_assert_response_message_allowed(
2214 $transaction,
2215 $response,
2216 'respond()',
2217 );
2218 20 $self->_assert_response_content_length(
2219 $transaction,
2220 $response,
2221 'respond()',
2222 );
2223 17 _assert_capsule_protocol_response(
2224 $response,
2225 'respond()',
2226 );
2227  
2228 17 ▶ croak 'final response status must be 200 through 599'
Branch: 1 branch
BranchTrueFalseTotal
if $response->status < 200 0 17 17
2229 if $response->status < 200;
2230  
2231 17 $self->{response_sent}{ $transaction->stream_id } = 1;
2232  
2233 17 my $ok = eval {
2234 17 $self->_submit_response(
2235 $transaction->stream_id,
2236 $response,
2237 );
2238 17 1;
2239 };
2240  
2241 17 ▶ if (!$ok) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($ok) 0 17 17
2242 0 delete $self->{response_sent}{ $transaction->stream_id };
2243 0 die $@;
2244 }
2245  
2246 17 $transaction->_mark_response_started;
2247 17 $self->_maybe_complete_transaction($transaction->stream_id);
2248 17 return $transaction;
2249 }
2250  
2251 2 ▶sub _write_stream_body {
Subroutine _write_stream_body: called CC=11 SCAR=31.2
2252 2 my ($self, $transaction, $bytes, $final, $operation) = @_;
2253  
2254 croak "$operation(): Transaction does not belong to this HTTP/3 connection"
2255 unless blessed($transaction)
2256 && $transaction->isa('Unblock::HTTP3::Transaction')
2257 && defined($self->{transactions}{ $transaction->stream_id })
2258 2 ▶ && $self->{transactions}{ $transaction->stream_id } == $transaction;
Branch: 1 branch
BranchTrueFalseTotal
unless builtin::blessed($transaction) and $transaction->isa("Unblock::HTTP3::Transaction") and defined $self->{"transactions"}{$transaction->stream_id} and $self->{"transactions"}{$transaction->stream_id} == $transaction 0 2 2
Condition33%3/9
builtin::blessed($transaction) and $transaction->isa("Unblock::HTTP3::Transaction") and defined $self->{"transactions"}{$transaction->stream_id} and $self->{"transactions"}{$transaction->stream_id} == $transaction
!ll&&!rl&&r
002
builtin::blessed($transaction) and $transaction->isa("Unblock::HTTP3::Transaction") and defined $self->{"transactions"}{$transaction->stream_id}
!ll&&!rl&&r
002
builtin::blessed($transaction) and $transaction->isa("Unblock::HTTP3::Transaction")
!ll&&!rl&&r
002
MC/DC0%0/4
builtin::blessed($transaction) and $transaction->isa("Unblock::HTTP3::Transaction") and defined $self->{"transactions"}{$transaction->stream_id} and $self->{"transactions"}{$transaction->stream_id} == $transaction
builtin::blessed($transaction) $transaction->isa("Unblock::HTTP3::Transaction") defined $self->{"transactions"}{$transaction->stream_id} $self->{"transactions"}{$transaction->stream_id} == $transaction
Truth table20%1/5
A and B and C and D
A= builtin::blessed($transaction)B= $transaction->isa("Unblock::HTTP3::Transaction")C= defined $self->{"transactions"}{$transaction->stream_id}D= $self->{"transactions"}{$transaction->stream_id} == $transaction
ABCDresult
0XXX0
10XX0
110X0
11100
11111
2259  
2260 2 my $body;
2261  
2262 2 ▶ if ($self->{role} eq 'client') {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'role'} eq 'client') { } 0 2 2
2263 0 ▶ croak "$operation(): Transaction has no streaming Request body"
Branch: 1 branch
BranchTrueFalseTotal
unless $transaction->_request_is_streaming 0 0 0
2264 unless $transaction->_request_is_streaming;
2265 0 $body = $transaction->request_body;
2266 } else {
2267 2 ▶ croak "$operation(): Transaction has no streaming Response body"
Branch: 1 branch
BranchTrueFalseTotal
unless $transaction->_response_is_streaming and $transaction->is_response_started 0 2 2
Condition33%1/3
$transaction->_response_is_streaming and $transaction->is_response_started
!ll&&!rl&&r
002
MC/DC0%0/2
$transaction->_response_is_streaming and $transaction->is_response_started
$transaction->_response_is_streaming $transaction->is_response_started
Truth table33%1/3
A and B
A= $transaction->_response_is_streamingB= $transaction->is_response_started
ABresult
0X0
100
111
2268 unless $transaction->_response_is_streaming
2269 && $transaction->is_response_started;
2270 $body = $transaction->{response_body}
2271 2 ▶ or croak "$operation(): Transaction has no streaming Response body";
Branch: 1 branch
BranchTrueFalseTotal
$body = $transaction->{"response_body"} or croak("$operation(): Transaction has no streaming Response body") 2 0 2
2272 }
2273  
2274 return $final
2275 2 ▶ ? do {
Branch: 1 branch
BranchTrueFalseTotal
$final ? : 1 1 2
2276 1 $body->complete($bytes);
2277 1 1;
2278 }
2279 : $body->write($bytes);
2280 }
2281  
2282 35 ▶sub _write_transaction_body {
Subroutine _write_transaction_body: called CC=17 SCAR=31.7
2283 35 my ($self, $transaction, $kind, $bytes, $final, $operation) = @_;
2284  
2285 croak "$operation(): Transaction does not belong to this HTTP/3 connection"
2286 unless blessed($transaction)
2287 && $transaction->isa('Unblock::HTTP3::Transaction')
2288 && defined($self->{transactions}{ $transaction->stream_id })
2289 35 ▶ && $self->{transactions}{ $transaction->stream_id } == $transaction;
Branch: 1 branch
BranchTrueFalseTotal
unless builtin::blessed($transaction) and $transaction->isa("Unblock::HTTP3::Transaction") and defined $self->{"transactions"}{$transaction->stream_id} and $self->{"transactions"}{$transaction->stream_id} == $transaction 0 35 35
Condition33%3/9
builtin::blessed($transaction) and $transaction->isa("Unblock::HTTP3::Transaction") and defined $self->{"transactions"}{$transaction->stream_id} and $self->{"transactions"}{$transaction->stream_id} == $transaction
!ll&&!rl&&r
0035
builtin::blessed($transaction) and $transaction->isa("Unblock::HTTP3::Transaction") and defined $self->{"transactions"}{$transaction->stream_id}
!ll&&!rl&&r
0035
builtin::blessed($transaction) and $transaction->isa("Unblock::HTTP3::Transaction")
!ll&&!rl&&r
0035
MC/DC0%0/4
builtin::blessed($transaction) and $transaction->isa("Unblock::HTTP3::Transaction") and defined $self->{"transactions"}{$transaction->stream_id} and $self->{"transactions"}{$transaction->stream_id} == $transaction
builtin::blessed($transaction) $transaction->isa("Unblock::HTTP3::Transaction") defined $self->{"transactions"}{$transaction->stream_id} $self->{"transactions"}{$transaction->stream_id} == $transaction
Truth table20%1/5
A and B and C and D
A= builtin::blessed($transaction)B= $transaction->isa("Unblock::HTTP3::Transaction")C= defined $self->{"transactions"}{$transaction->stream_id}D= $self->{"transactions"}{$transaction->stream_id} == $transaction
ABCDresult
0XXX0
10XX0
110X0
11100
11111
2290  
2291 35 my $id = $transaction->stream_id;
2292 35 my $message;
2293  
2294 35 ▶ if ($kind eq 'request') {
Branch: 2 branches
BranchTrueFalseTotal
if ($kind eq 'request') { } 20 15 35
elsif ($kind eq 'response') { } 15 0 15
2295 croak "$operation(): request body production requires a client connection"
2296 20 ▶ unless $self->{role} eq 'client';
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"role"} eq "client" 0 20 20
2297  
2298 20 $message = $transaction->request;
2299  
2300 20 ▶ croak "$operation(): Request is not configured for incremental body production"
Branch: 1 branch
BranchTrueFalseTotal
unless $transaction->_request_is_streaming 0 20 20
2301 unless $transaction->_request_is_streaming;
2302 } elsif ($kind eq 'response') {
2303 croak "$operation(): response body production requires a server connection"
2304 15 ▶ unless $self->{role} eq 'server';
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"role"} eq "server" 0 15 15
2305  
2306 15 ▶ $message = $transaction->response
Branch: 1 branch
BranchTrueFalseTotal
$message = $transaction->response or croak("$operation(): Transaction has no Response") 15 0 15
2307 or croak "$operation(): Transaction has no Response";
2308  
2309 15 $self->_assert_response_body_allowed(
2310 $transaction,
2311 $message,
2312 $operation,
2313 );
2314  
2315 15 ▶ croak "$operation(): Response is not configured for incremental body production"
Branch: 1 branch
BranchTrueFalseTotal
unless $transaction->_response_is_streaming 0 15 15
2316 unless $transaction->_response_is_streaming;
2317  
2318 15 ▶ if (!$self->{response_sent}{$id}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"response_sent"}{$id}) 7 8 15
2319 7 $self->{response_sent}{$id} = 1;
2320  
2321 7 my $ok = eval {
2322 7 $self->_submit_response($id, $message);
2323 7 1;
2324 };
2325  
2326 7 ▶ if (!$ok) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($ok) 0 7 7
2327 0 delete $self->{response_sent}{$id};
2328 0 delete $self->{body_bytes_sent}{$id};
2329 0 die $@;
2330 }
2331  
2332 7 $transaction->_mark_response_started;
2333 }
2334 } else {
2335 0 croak "$operation(): unsupported HTTP body producer '$kind'";
2336 }
2337  
2338 35 ▶ $self->_assert_incremental_content_length(
Branch: 1 branch
BranchTrueFalseTotal
$final ? : 17 18 35
2339 $transaction,
2340 $kind,
2341 $message,
2342 $bytes,
2343 $final ? 1 : 0,
2344 $operation,
2345 );
2346  
2347 $self->{native}->append_body(
2348 35 ▶ $id,
Branch: 1 branch
BranchTrueFalseTotal
$final ? : 17 18 35
2349 $bytes,
2350 $final ? 1 : 0,
2351 );
2352  
2353 35 $self->_drain_output;
2354 35 $self->_maybe_complete_transaction($id);
2355  
2356 return $self->{native}->streaming_retained_bytes
2357 < $self->{send_buffer_limit}
2358 35 ▶ ? 1
Branch: 1 branch
BranchTrueFalseTotal
$self->{'native'}->streaming_retained_bytes < $self->{'send_buffer_limit'} ? : 33 2 35
2359 : 0;
2360 }
2361  
2362 351 ▶sub _drain_body_producers {
Subroutine _drain_body_producers: called CC=6 SCAR=17.9
2363 351 my ($self) = @_;
2364  
2365 return
2366 if $self->{native}->streaming_retained_bytes
2367 351 ▶ >= $self->{send_buffer_limit};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"native"}->streaming_retained_bytes >= $self->{"send_buffer_limit"} 7 344 351
2368  
2369 344 for my $transaction (values %{ $self->{transactions} }) {
2370 460 ▶ next if $transaction->is_terminal;
Branch: 1 branch
BranchTrueFalseTotal
if $transaction->is_terminal 174 286 460
2371  
2372 286 ▶ if (my $body = $transaction->_request_body_object) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $body = $transaction->_request_body_object) 104 182 286
2373 104 $body->_drain;
2374 }
2375  
2376 286 ▶ if (my $body = $transaction->_response_body_object) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $body = $transaction->_response_body_object) 55 231 286
2377 55 $body->_drain;
2378 }
2379 }
2380  
2381 344 return;
2382 }
2383  
2384 24 ▶sub _consume_received_body {
Subroutine _consume_received_body: called CC=16 SCAR=35.4
2385 24 my ($self, $transaction, $kind, $amount) = @_;
2386  
2387 croak 'received body Transaction does not belong to this HTTP/3 connection'
2388 unless blessed($transaction)
2389 && $transaction->isa('Unblock::HTTP3::Transaction')
2390 && defined($self->{transactions}{ $transaction->stream_id })
2391 24 ▶ && $self->{transactions}{ $transaction->stream_id } == $transaction;
Branch: 1 branch
BranchTrueFalseTotal
unless builtin::blessed($transaction) and $transaction->isa("Unblock::HTTP3::Transaction") and defined $self->{"transactions"}{$transaction->stream_id} and $self->{"transactions"}{$transaction->stream_id} == $transaction 0 24 24
Condition33%3/9
builtin::blessed($transaction) and $transaction->isa("Unblock::HTTP3::Transaction") and defined $self->{"transactions"}{$transaction->stream_id} and $self->{"transactions"}{$transaction->stream_id} == $transaction
!ll&&!rl&&r
0024
builtin::blessed($transaction) and $transaction->isa("Unblock::HTTP3::Transaction") and defined $self->{"transactions"}{$transaction->stream_id}
!ll&&!rl&&r
0024
builtin::blessed($transaction) and $transaction->isa("Unblock::HTTP3::Transaction")
!ll&&!rl&&r
0024
MC/DC0%0/4
builtin::blessed($transaction) and $transaction->isa("Unblock::HTTP3::Transaction") and defined $self->{"transactions"}{$transaction->stream_id} and $self->{"transactions"}{$transaction->stream_id} == $transaction
builtin::blessed($transaction) $transaction->isa("Unblock::HTTP3::Transaction") defined $self->{"transactions"}{$transaction->stream_id} $self->{"transactions"}{$transaction->stream_id} == $transaction
Truth table20%1/5
A and B and C and D
A= builtin::blessed($transaction)B= $transaction->isa("Unblock::HTTP3::Transaction")C= defined $self->{"transactions"}{$transaction->stream_id}D= $self->{"transactions"}{$transaction->stream_id} == $transaction
ABCDresult
0XXX0
10XX0
110X0
11100
11111
2392  
2393 24 ▶ croak 'received body consume amount must be a non-negative integer'
Branch: 1 branch
BranchTrueFalseTotal
unless defined $amount and not ref $amount and $amount =~ /\A[0-9]+\z/ 0 24 24
Condition33%2/6
defined $amount and not ref $amount and $amount =~ /\A[0-9]+\z/
!ll&&!rl&&r
0024
defined $amount and not ref $amount
!ll&&!rl&&r
0024
MC/DC0%0/3
defined $amount and not ref $amount and $amount =~ /\A[0-9]+\z/
defined $amount not ref $amount $amount =~ /\A[0-9]+\z/
Truth table25%1/4
A and not(B) and C
A= defined $amountB= not ref $amountC= $amount =~ /\A[0-9]+\z/
ABCresult
0XX0
10X0
1100
1111
2394 unless defined($amount)
2395 && !ref($amount)
2396 && $amount =~ /\A[0-9]+\z/;
2397  
2398 24 ▶ return if $amount == 0;
Branch: 1 branch
BranchTrueFalseTotal
if $amount == 0 0 24 24
2399  
2400 croak 'request receive bodies exist only on server connections'
2401 24 ▶ if $kind eq 'request' && $self->{role} ne 'server';
Branch: 1 branch
BranchTrueFalseTotal
if $kind eq "request" and $self->{"role"} ne "server" 0 24 24
Condition66%2/3
$kind eq "request" and $self->{"role"} ne "server"
!ll&&!rl&&r
1770
MC/DC0%0/2
$kind eq "request" and $self->{"role"} ne "server"
$kind eq "request" $self->{"role"} ne "server"
Truth table66%2/3
A and B
A= $kind eq "request"B= $self->{"role"} ne "server"
ABresult
0X0
100
111
2402 croak 'response receive bodies exist only on client connections'
2403 24 ▶ if $kind eq 'response' && $self->{role} ne 'client';
Branch: 1 branch
BranchTrueFalseTotal
if $kind eq "response" and $self->{"role"} ne "client" 0 24 24
Condition66%2/3
$kind eq "response" and $self->{"role"} ne "client"
!ll&&!rl&&r
7170
MC/DC0%0/2
$kind eq "response" and $self->{"role"} ne "client"
$kind eq "response" $self->{"role"} ne "client"
Truth table66%2/3
A and B
A= $kind eq "response"B= $self->{"role"} ne "client"
ABresult
0X0
100
111
2404 24 ▶ croak "unsupported received body kind '$kind'"
Branch: 1 branch
BranchTrueFalseTotal
if $kind ne "request" and $kind ne "response" 0 24 24
Condition66%2/3
$kind ne "request" and $kind ne "response"
!ll&&!rl&&r
7170
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"
ABresult
0X0
100
111
2405 if $kind ne 'request' && $kind ne 'response';
2406  
2407 24 ▶ my $stream = $self->{streams}{ $transaction->stream_id }
Branch: 1 branch
BranchTrueFalseTotal
my $stream = $self->{"streams"}{$transaction->stream_id} or croak("received body stream is no longer available") 24 0 24
2408 or croak 'received body stream is no longer available';
2409  
2410 24 $stream->consume(0 + $amount);
2411 24 return;
2412 }
2413  
2414 1 ▶sub _cancel_transaction {
Subroutine _cancel_transaction: called CC=11 SCAR=28.0
2415 1 my ($self, $transaction) = @_;
2416  
2417 croak 'Transaction does not belong to this HTTP/3 connection'
2418 unless blessed($transaction)
2419 && $transaction->isa('Unblock::HTTP3::Transaction')
2420 && defined($self->{transactions}{ $transaction->stream_id })
2421 1 ▶ && $self->{transactions}{ $transaction->stream_id } == $transaction;
Branch: 1 branch
BranchTrueFalseTotal
unless builtin::blessed($transaction) and $transaction->isa("Unblock::HTTP3::Transaction") and defined $self->{"transactions"}{$transaction->stream_id} and $self->{"transactions"}{$transaction->stream_id} == $transaction 0 1 1
Condition33%3/9
builtin::blessed($transaction) and $transaction->isa("Unblock::HTTP3::Transaction") and defined $self->{"transactions"}{$transaction->stream_id} and $self->{"transactions"}{$transaction->stream_id} == $transaction
!ll&&!rl&&r
001
builtin::blessed($transaction) and $transaction->isa("Unblock::HTTP3::Transaction") and defined $self->{"transactions"}{$transaction->stream_id}
!ll&&!rl&&r
001
builtin::blessed($transaction) and $transaction->isa("Unblock::HTTP3::Transaction")
!ll&&!rl&&r
001
MC/DC0%0/4
builtin::blessed($transaction) and $transaction->isa("Unblock::HTTP3::Transaction") and defined $self->{"transactions"}{$transaction->stream_id} and $self->{"transactions"}{$transaction->stream_id} == $transaction
builtin::blessed($transaction) $transaction->isa("Unblock::HTTP3::Transaction") defined $self->{"transactions"}{$transaction->stream_id} $self->{"transactions"}{$transaction->stream_id} == $transaction
Truth table20%1/5
A and B and C and D
A= builtin::blessed($transaction)B= $transaction->isa("Unblock::HTTP3::Transaction")C= defined $self->{"transactions"}{$transaction->stream_id}D= $self->{"transactions"}{$transaction->stream_id} == $transaction
ABCDresult
0XXX0
10XX0
110X0
11100
11111
2422  
2423 1 ▶ return $transaction if $transaction->is_terminal;
Branch: 1 branch
BranchTrueFalseTotal
if $transaction->is_terminal 0 1 1
2424  
2425 1 my $id = $transaction->stream_id;
2426 1 my $stream = $self->{streams}{$id};
2427  
2428 1 ▶ if (defined $stream) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $stream) 1 0 1
2429 1 ▶ if ($stream->can_receive && !$stream->remote_finished) {
Branch: 1 branch
BranchTrueFalseTotal
if ($stream->can_receive and not $stream->remote_finished) 1 0 1
Condition33%1/3
$stream->can_receive and not $stream->remote_finished
!ll&&!rl&&r
001
MC/DC0%0/2
$stream->can_receive and not $stream->remote_finished
$stream->can_receive not $stream->remote_finished
Truth table33%1/3
A and not(B)
A= $stream->can_receiveB= not $stream->remote_finished
ABresult
0X0
100
111
2430 1 $self->{native}->shutdown_stream_read($id);
2431 1 $stream->stop_sending($H3_REQUEST_CANCELLED);
2432 1 $transaction->_mark_local_stop_sending($H3_REQUEST_CANCELLED);
2433 }
2434  
2435 1 ▶ if ($stream->can_send && !defined($stream->local_reset_code)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($stream->can_send and not defined $stream->local_reset_code) 1 0 1
Condition33%1/3
$stream->can_send and not defined $stream->local_reset_code
!ll&&!rl&&r
001
MC/DC0%0/2
$stream->can_send and not defined $stream->local_reset_code
$stream->can_send not defined $stream->local_reset_code
Truth table33%1/3
A and not(B)
A= $stream->can_sendB= not defined $stream->local_reset_code
ABresult
0X0
100
111
2436 1 $self->{native}->shutdown_stream_write($id);
2437 1 $stream->reset($H3_REQUEST_CANCELLED);
2438 1 $transaction->_mark_local_reset($H3_REQUEST_CANCELLED);
2439 }
2440 }
2441  
2442 1 $self->{native}->discard_body($id);
2443  
2444 1 $transaction->_mark_cancelled;
2445 1 return $transaction;
2446 }
2447  
2448 10 ▶sub _transaction_priority {
Subroutine _transaction_priority: called CC=8 SCAR=23.1
2449 10 my ($self, $transaction) = @_;
2450  
2451 croak 'priority Transaction does not belong to this connection'
2452 unless blessed($transaction)
2453 && $transaction->isa('Unblock::HTTP3::Transaction')
2454 && defined($self->{transactions}{ $transaction->stream_id })
2455 10 ▶ && $self->{transactions}{ $transaction->stream_id } == $transaction;
Branch: 1 branch
BranchTrueFalseTotal
unless builtin::blessed($transaction) and $transaction->isa("Unblock::HTTP3::Transaction") and defined $self->{"transactions"}{$transaction->stream_id} and $self->{"transactions"}{$transaction->stream_id} == $transaction 0 10 10
Condition33%3/9
builtin::blessed($transaction) and $transaction->isa("Unblock::HTTP3::Transaction") and defined $self->{"transactions"}{$transaction->stream_id} and $self->{"transactions"}{$transaction->stream_id} == $transaction
!ll&&!rl&&r
0010
builtin::blessed($transaction) and $transaction->isa("Unblock::HTTP3::Transaction") and defined $self->{"transactions"}{$transaction->stream_id}
!ll&&!rl&&r
0010
builtin::blessed($transaction) and $transaction->isa("Unblock::HTTP3::Transaction")
!ll&&!rl&&r
0010
MC/DC0%0/4
builtin::blessed($transaction) and $transaction->isa("Unblock::HTTP3::Transaction") and defined $self->{"transactions"}{$transaction->stream_id} and $self->{"transactions"}{$transaction->stream_id} == $transaction
builtin::blessed($transaction) $transaction->isa("Unblock::HTTP3::Transaction") defined $self->{"transactions"}{$transaction->stream_id} $self->{"transactions"}{$transaction->stream_id} == $transaction
Truth table20%1/5
A and B and C and D
A= builtin::blessed($transaction)B= $transaction->isa("Unblock::HTTP3::Transaction")C= defined $self->{"transactions"}{$transaction->stream_id}D= $self->{"transactions"}{$transaction->stream_id} == $transaction
ABCDresult
0XXX0
10XX0
110X0
11100
11111
2456  
2457 10 ▶ if (
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"role"} eq "server" and not $transaction->is_terminal) 7 3 10
Condition66%2/3
$self->{"role"} eq "server" and not $transaction->is_terminal
!ll&&!rl&&r
307
MC/DC50%1/2
$self->{"role"} eq "server" and not $transaction->is_terminal
$self->{"role"} eq "server" not $transaction->is_terminal
Truth table66%2/3
A and not(B)
A= $self->{"role"} eq "server"B= not $transaction->is_terminal
ABresult
0X0
100
111
2458 $self->{role} eq 'server'
2459 && !$transaction->is_terminal
2460 ) {
2461 my $priority = $self->{native}->get_server_stream_priority(
2462 7 $transaction->stream_id,
2463 );
2464  
2465 return {
2466 7 ▶ urgency => 0 + $priority->[0],
Branch: 1 branch
BranchTrueFalseTotal
$priority->[1] ? : 5 2 7
2467 incremental => $priority->[1] ? 1 : 0,
2468 };
2469 }
2470  
2471 3 return { %{ $transaction->{priority} } };
2472 }
2473  
2474 2 ▶sub _set_transaction_priority {
Subroutine _set_transaction_priority: called CC=8 SCAR=23.2
2475 2 my ($self, $transaction, $priority) = @_;
2476  
2477 croak 'priority Transaction does not belong to this connection'
2478 unless blessed($transaction)
2479 && $transaction->isa('Unblock::HTTP3::Transaction')
2480 && defined($self->{transactions}{ $transaction->stream_id })
2481 2 ▶ && $self->{transactions}{ $transaction->stream_id } == $transaction;
Branch: 1 branch
BranchTrueFalseTotal
unless builtin::blessed($transaction) and $transaction->isa("Unblock::HTTP3::Transaction") and defined $self->{"transactions"}{$transaction->stream_id} and $self->{"transactions"}{$transaction->stream_id} == $transaction 0 2 2
Condition33%3/9
builtin::blessed($transaction) and $transaction->isa("Unblock::HTTP3::Transaction") and defined $self->{"transactions"}{$transaction->stream_id} and $self->{"transactions"}{$transaction->stream_id} == $transaction
!ll&&!rl&&r
002
builtin::blessed($transaction) and $transaction->isa("Unblock::HTTP3::Transaction") and defined $self->{"transactions"}{$transaction->stream_id}
!ll&&!rl&&r
002
builtin::blessed($transaction) and $transaction->isa("Unblock::HTTP3::Transaction")
!ll&&!rl&&r
002
MC/DC0%0/4
builtin::blessed($transaction) and $transaction->isa("Unblock::HTTP3::Transaction") and defined $self->{"transactions"}{$transaction->stream_id} and $self->{"transactions"}{$transaction->stream_id} == $transaction
builtin::blessed($transaction) $transaction->isa("Unblock::HTTP3::Transaction") defined $self->{"transactions"}{$transaction->stream_id} $self->{"transactions"}{$transaction->stream_id} == $transaction
Truth table20%1/5
A and B and C and D
A= builtin::blessed($transaction)B= $transaction->isa("Unblock::HTTP3::Transaction")C= defined $self->{"transactions"}{$transaction->stream_id}D= $self->{"transactions"}{$transaction->stream_id} == $transaction
ABCDresult
0XXX0
10XX0
110X0
11100
11111
2482 2 ▶ croak 'priority must be a hash reference'
Branch: 1 branch
BranchTrueFalseTotal
unless ref $priority eq "HASH" 0 2 2
2483 unless ref($priority) eq 'HASH';
2484  
2485 2 my $stream_id = $transaction->stream_id;
2486  
2487 2 ▶ if ($self->{role} eq 'client') {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'role'} eq 'client') { } 1 1 2
2488 1 my $field = Unblock::HTTP3::Transaction::_priority_field(
2489 $priority,
2490 );
2491  
2492 $self->{native}->set_client_stream_priority(
2493 1 $stream_id,
2494 $field,
2495 );
2496 } else {
2497 $self->{native}->set_server_stream_priority(
2498 $stream_id,
2499 $priority->{urgency},
2500 1 ▶ $priority->{incremental} ? 1 : 0,
Branch: 1 branch
BranchTrueFalseTotal
$priority->{'incremental'} ? : 1 0 1
2501 );
2502 }
2503  
2504 2 $transaction->{priority} = { %$priority };
2505 2 $self->_service;
2506  
2507 2 return;
2508 }
2509  
2510 8 ▶sub _send_transaction_datagram {
Subroutine _send_transaction_datagram: called CC=14 SCAR=31.3
2511 8 my ($self, $transaction, $bytes) = @_;
2512  
2513 croak 'HTTP Datagram Transaction does not belong to this connection'
2514 unless blessed($transaction)
2515 && $transaction->isa('Unblock::HTTP3::Transaction')
2516 && defined($self->{transactions}{ $transaction->stream_id })
2517 8 ▶ && $self->{transactions}{ $transaction->stream_id } == $transaction;
Branch: 1 branch
BranchTrueFalseTotal
unless builtin::blessed($transaction) and $transaction->isa("Unblock::HTTP3::Transaction") and defined $self->{"transactions"}{$transaction->stream_id} and $self->{"transactions"}{$transaction->stream_id} == $transaction 0 8 8
Condition33%3/9
builtin::blessed($transaction) and $transaction->isa("Unblock::HTTP3::Transaction") and defined $self->{"transactions"}{$transaction->stream_id} and $self->{"transactions"}{$transaction->stream_id} == $transaction
!ll&&!rl&&r
008
builtin::blessed($transaction) and $transaction->isa("Unblock::HTTP3::Transaction") and defined $self->{"transactions"}{$transaction->stream_id}
!ll&&!rl&&r
008
builtin::blessed($transaction) and $transaction->isa("Unblock::HTTP3::Transaction")
!ll&&!rl&&r
008
MC/DC0%0/4
builtin::blessed($transaction) and $transaction->isa("Unblock::HTTP3::Transaction") and defined $self->{"transactions"}{$transaction->stream_id} and $self->{"transactions"}{$transaction->stream_id} == $transaction
builtin::blessed($transaction) $transaction->isa("Unblock::HTTP3::Transaction") defined $self->{"transactions"}{$transaction->stream_id} $self->{"transactions"}{$transaction->stream_id} == $transaction
Truth table20%1/5
A and B and C and D
A= builtin::blessed($transaction)B= $transaction->isa("Unblock::HTTP3::Transaction")C= defined $self->{"transactions"}{$transaction->stream_id}D= $self->{"transactions"}{$transaction->stream_id} == $transaction
ABCDresult
0XXX0
10XX0
110X0
11100
11111
2518 8 ▶ croak 'HTTP Datagrams are not enabled for this Transaction'
Branch: 1 branch
BranchTrueFalseTotal
unless $transaction->datagrams_enabled 0 8 8
2519 unless $transaction->datagrams_enabled;
2520 8 ▶ croak 'HTTP Datagram payload is required'
Branch: 1 branch
BranchTrueFalseTotal
unless defined $bytes 0 8 8
2521 unless defined $bytes;
2522 8 ▶ croak 'HTTP Datagram payload must be bytes, not a reference'
Branch: 1 branch
BranchTrueFalseTotal
if ref $bytes 0 8 8
2523 if ref($bytes);
2524 8 ▶ croak 'HTTP/3 DATAGRAM is not negotiated with the peer'
Branch: 1 branch
BranchTrueFalseTotal
unless $self->can_send_http_datagrams 0 8 8
2525 unless $self->can_send_http_datagrams;
2526  
2527 8 my $id = $transaction->stream_id;
2528 croak 'HTTP Datagram request stream send side is closed'
2529 8 ▶ if $self->{output_finished}{$id};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"output_finished"}{$id} 0 8 8
2530  
2531 8 my $stream = $self->{streams}{$id};
2532 8 ▶ croak 'HTTP Datagram request stream is no longer available'
Branch: 1 branch
BranchTrueFalseTotal
unless defined $stream 0 8 8
2533 unless defined $stream;
2534 8 ▶ croak 'HTTP Datagram request stream send side is reset'
Branch: 1 branch
BranchTrueFalseTotal
if defined $stream->local_reset_code 0 8 8
2535 if defined $stream->local_reset_code;
2536  
2537 8 my $quarter = $id >> 2;
2538 8 my $prefix = _encode_http3_varint($quarter);
2539 8 my $max = $self->_transaction_datagram_payload_size($transaction);
2540  
2541 8 ▶ croak "HTTP Datagram payload exceeds current path capacity $max"
Branch: 1 branch
BranchTrueFalseTotal
if length $bytes > $max 0 8 8
2542 if length($bytes) > $max;
2543  
2544 8 ▶ return $self->{quic}->send_datagram($prefix . $bytes) ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$self->{'quic'}->send_datagram($prefix . $bytes) ? : 8 0 8
2545 }
2546  
2547 10 ▶sub _transaction_datagram_payload_size {
Subroutine _transaction_datagram_payload_size: called CC=10 SCAR=28.6
2548 10 my ($self, $transaction) = @_;
2549  
2550 croak 'HTTP Datagram Transaction does not belong to this connection'
2551 unless blessed($transaction)
2552 && $transaction->isa('Unblock::HTTP3::Transaction')
2553 && defined($self->{transactions}{ $transaction->stream_id })
2554 10 ▶ && $self->{transactions}{ $transaction->stream_id } == $transaction;
Branch: 1 branch
BranchTrueFalseTotal
unless builtin::blessed($transaction) and $transaction->isa("Unblock::HTTP3::Transaction") and defined $self->{"transactions"}{$transaction->stream_id} and $self->{"transactions"}{$transaction->stream_id} == $transaction 0 10 10
Condition33%3/9
builtin::blessed($transaction) and $transaction->isa("Unblock::HTTP3::Transaction") and defined $self->{"transactions"}{$transaction->stream_id} and $self->{"transactions"}{$transaction->stream_id} == $transaction
!ll&&!rl&&r
0010
builtin::blessed($transaction) and $transaction->isa("Unblock::HTTP3::Transaction") and defined $self->{"transactions"}{$transaction->stream_id}
!ll&&!rl&&r
0010
builtin::blessed($transaction) and $transaction->isa("Unblock::HTTP3::Transaction")
!ll&&!rl&&r
0010
MC/DC0%0/4
builtin::blessed($transaction) and $transaction->isa("Unblock::HTTP3::Transaction") and defined $self->{"transactions"}{$transaction->stream_id} and $self->{"transactions"}{$transaction->stream_id} == $transaction
builtin::blessed($transaction) $transaction->isa("Unblock::HTTP3::Transaction") defined $self->{"transactions"}{$transaction->stream_id} $self->{"transactions"}{$transaction->stream_id} == $transaction
Truth table20%1/5
A and B and C and D
A= builtin::blessed($transaction)B= $transaction->isa("Unblock::HTTP3::Transaction")C= defined $self->{"transactions"}{$transaction->stream_id}D= $self->{"transactions"}{$transaction->stream_id} == $transaction
ABCDresult
0XXX0
10XX0
110X0
11100
11111
2555  
2556 10 ▶ return 0 unless $transaction->datagrams_enabled;
Branch: 1 branch
BranchTrueFalseTotal
unless $transaction->datagrams_enabled 0 10 10
2557 10 ▶ return 0 unless $self->can_send_http_datagrams;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->can_send_http_datagrams 0 10 10
2558  
2559 10 my $capacity = $self->{quic}->max_datagram_payload_size;
2560 10 ▶ return 0 unless defined($capacity) && $capacity > 0;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $capacity and $capacity > 0 0 10 10
Condition33%1/3
defined $capacity and $capacity > 0
!ll&&!rl&&r
0010
MC/DC0%0/2
defined $capacity and $capacity > 0
defined $capacity $capacity > 0
Truth table33%1/3
A and B
A= defined $capacityB= $capacity > 0
ABresult
0X0
100
111
2561  
2562 10 my $prefix = _encode_http3_varint($transaction->stream_id >> 2);
2563 10 my $available = $capacity - length($prefix);
2564  
2565 10 ▶ return $available > 0 ? $available : 0;
Branch: 1 branch
BranchTrueFalseTotal
$available > 0 ? : 10 0 10
2566 }
2567  
2568 6 ▶sub _buffer_transaction_datagram {
Subroutine _buffer_transaction_datagram: called CC=3 SCAR=11.0
2569 6 my ($self, $transaction, $bytes) = @_;
2570  
2571 6 my $length = length($bytes);
2572  
2573 6 ▶ if (
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"datagram_buffered_count"} >= $self->{"max_buffered_datagrams"} or $self->{"datagram_buffered_bytes"} + $length > $self->{"max_buffered_datagram_bytes"}) 1 5 6
Condition66%2/3
$self->{"datagram_buffered_count"} >= $self->{"max_buffered_datagrams"} or $self->{"datagram_buffered_bytes"} + $length > $self->{"max_buffered_datagram_bytes"}
l!l&&r!l&&!r
105
MC/DC50%1/2
$self->{"datagram_buffered_count"} >= $self->{"max_buffered_datagrams"} or $self->{"datagram_buffered_bytes"} + $length > $self->{"max_buffered_datagram_bytes"}
$self->{"datagram_buffered_count"} >= $self->{"max_buffered_datagrams"} $self->{"datagram_buffered_bytes"} + $length > $self->{"max_buffered_datagram_bytes"}
Truth table66%2/3
A or B
A= $self->{"datagram_buffered_count"} >= $self->{"max_buffered_datagrams"}B= $self->{"datagram_buffered_bytes"} + $length > $self->{"max_buffered_datagram_bytes"}
ABresult
1X1
011
000
2574 $self->{datagram_buffered_count} >= $self->{max_buffered_datagrams}
2575 || $self->{datagram_buffered_bytes} + $length
2576 > $self->{max_buffered_datagram_bytes}
2577 ) {
2578 1 ++$self->{datagram_receive_drops};
2579 1 return;
2580 }
2581  
2582 5 ++$self->{datagram_buffered_count};
2583 5 $self->{datagram_buffered_bytes} += $length;
2584 5 $transaction->_enqueue_datagram($bytes);
2585 5 return 1;
2586 }
2587  
2588 6 ▶sub _datagram_dequeued {
Subroutine _datagram_dequeued: called CC=3 SCAR=11.3
2589 6 my ($self, $length) = @_;
2590  
2591 --$self->{datagram_buffered_count}
2592 6 ▶ if $self->{datagram_buffered_count} > 0;
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"datagram_buffered_count"} > 0 6 0 6
2593 6 $self->{datagram_buffered_bytes} -= $length;
2594 $self->{datagram_buffered_bytes} = 0
2595 6 ▶ if $self->{datagram_buffered_bytes} < 0;
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"datagram_buffered_bytes"} < 0 0 6 6
2596  
2597 6 return;
2598 }
2599  
2600 1 ▶sub _reject_datagram_stream {
Subroutine _reject_datagram_stream: called CC=6 SCAR=18.9
2601 1 my ($self, $transaction, $reason) = @_;
2602  
2603 1 my $id = $transaction->stream_id;
2604 1 my $stream = $self->{streams}{$id};
2605  
2606 1 ▶ if (defined $stream) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $stream) 1 0 1
2607 1 ▶ if ($stream->can_receive && !$stream->remote_finished) {
Branch: 1 branch
BranchTrueFalseTotal
if ($stream->can_receive and not $stream->remote_finished) 1 0 1
Condition33%1/3
$stream->can_receive and not $stream->remote_finished
!ll&&!rl&&r
001
MC/DC0%0/2
$stream->can_receive and not $stream->remote_finished
$stream->can_receive not $stream->remote_finished
Truth table33%1/3
A and not(B)
A= $stream->can_receiveB= not $stream->remote_finished
ABresult
0X0
100
111
2608 1 $self->{native}->shutdown_stream_read($id);
2609 1 $stream->stop_sending($H3_DATAGRAM_ERROR);
2610 1 $transaction->_mark_local_stop_sending($H3_DATAGRAM_ERROR);
2611 }
2612  
2613 1 ▶ if ($stream->can_send && !$self->{output_finished}{$id}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($stream->can_send and not $self->{"output_finished"}{$id}) 1 0 1
Condition33%1/3
$stream->can_send and not $self->{"output_finished"}{$id}
!ll&&!rl&&r
001
MC/DC0%0/2
$stream->can_send and not $self->{"output_finished"}{$id}
$stream->can_send not $self->{"output_finished"}{$id}
Truth table33%1/3
A and not(B)
A= $stream->can_sendB= not $self->{"output_finished"}{$id}
ABresult
0X0
100
111
2614 1 $self->{native}->shutdown_stream_write($id);
2615 1 $stream->reset($H3_DATAGRAM_ERROR);
2616 1 $transaction->_mark_local_reset($H3_DATAGRAM_ERROR);
2617 }
2618 }
2619  
2620 1 $self->{native}->discard_body($id);
2621 1 $transaction->_mark_error($reason, $H3_DATAGRAM_ERROR);
2622 1 return;
2623 }
2624  
2625 9 ▶sub _receive_quic_datagram {
Subroutine _receive_quic_datagram: called CC=21 SCAR=35.1
2626 9 my ($self, $bytes, $early_data) = @_;
2627  
2628 9 ▶ return if $self->{failed};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"failed"} 0 9 9
2629  
2630 9 ▶ if ($early_data) {
Branch: 1 branch
BranchTrueFalseTotal
if ($early_data) 1 8 9
2631 1 ▶ return if $self->{role} ne 'server';
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"role"} ne "server" 0 1 1
2632  
2633 1 ▶ if (!defined($self->{remembered_local_settings})) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $self->{"remembered_local_settings"}) 0 1 1
2634 0 $self->_fail_connection(
2635 $H3_SETTINGS_ERROR,
2636 'received HTTP/3 0-RTT DATAGRAM without remembered_local_settings',
2637 );
2638 0 return;
2639 }
2640  
2641 # An unreliable DATAGRAM can race ahead of the client's 0-RTT
2642 # SETTINGS control stream. Drop it until current peer SETTINGS have
2643 # actually arrived; there is no safe request association yet.
2644 1 ▶ return unless $self->{peer_settings_received};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"peer_settings_received"} 0 1 1
2645 }
2646  
2647 9 ▶ if (!$self->{enable_http_datagrams}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"enable_http_datagrams"}) 0 9 9
2648 0 $self->_fail_connection(
2649 $H3_DATAGRAM_ERROR,
2650 'received QUIC DATAGRAM without local SETTINGS_H3_DATAGRAM',
2651 );
2652 0 return;
2653 }
2654  
2655 # A peer may send after it has sent its SETTINGS while the control-stream
2656 # bytes are still racing this unreliable DATAGRAM. Dropping is safer than
2657 # assigning semantics before the peer SETTINGS have been processed.
2658 9 ▶ return unless $self->{peer_settings_received};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"peer_settings_received"} 0 9 9
2659  
2660 9 ▶ if (!$self->{peer_h3_datagram}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"peer_h3_datagram"}) 0 9 9
2661 0 $self->_fail_connection(
2662 $H3_DATAGRAM_ERROR,
2663 'received QUIC DATAGRAM without peer SETTINGS_H3_DATAGRAM',
2664 );
2665 0 return;
2666 }
2667  
2668 9 my ($quarter, $prefix_length) = _decode_http3_varint($bytes, 0);
2669  
2670 9 ▶ if (!defined $quarter) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $quarter) 1 8 9
2671 1 $self->_fail_connection(
2672 $H3_DATAGRAM_ERROR,
2673 'HTTP Datagram is missing a complete Quarter Stream ID',
2674 );
2675 1 return;
2676 }
2677  
2678 8 ▶ if (_decimal_less_than($HTTP3_MAX_QUARTER_STREAM_ID, $quarter)) {
Branch: 1 branch
BranchTrueFalseTotal
if (_decimal_less_than($HTTP3_MAX_QUARTER_STREAM_ID, $quarter)) 0 8 8
2679 0 $self->_fail_connection(
2680 $H3_DATAGRAM_ERROR,
2681 'HTTP Datagram Quarter Stream ID exceeds the RFC 9297 maximum',
2682 );
2683 0 return;
2684 }
2685  
2686 8 my $id = (0 + $quarter) << 2;
2687 8 my $transaction = $self->{transactions}{$id};
2688  
2689 # RFC 9297 permits silently dropping a DATAGRAM that races ahead of the
2690 # request stream. The same treatment is appropriate after transaction
2691 # cleanup, where the receive side is already gone.
2692 8 ▶ return unless defined $transaction;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $transaction 0 8 8
2693  
2694 8 my $stream = $self->{streams}{$id};
2695 8 ▶ return unless defined $stream;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $stream 0 8 8
2696 8 ▶ return if $stream->remote_finished;
Branch: 1 branch
BranchTrueFalseTotal
if $stream->remote_finished 0 8 8
2697 8 ▶ return if defined $stream->remote_reset_code;
Branch: 1 branch
BranchTrueFalseTotal
if defined $stream->remote_reset_code 0 8 8
2698  
2699 8 ▶ if (
Branch: 1 branch
BranchTrueFalseTotal
if ($transaction->early_data and $self->{"role"} eq "server" and not $self->{"quic"}->ready) 1 7 8
Condition66%4/6
$transaction->early_data and $self->{"role"} eq "server" and not $self->{"quic"}->ready
!ll&&!rl&&r
701
$transaction->early_data and $self->{"role"} eq "server"
!ll&&!rl&&r
701
MC/DC33%1/3
$transaction->early_data and $self->{"role"} eq "server" and not $self->{"quic"}->ready
$transaction->early_data $self->{"role"} eq "server" not $self->{"quic"}->ready
Truth table50%2/4
A and B and not(C)
A= $transaction->early_dataB= $self->{"role"} eq "server"C= not $self->{"quic"}->ready
ABCresult
0XX0
10X0
1100
1111
2700 $transaction->early_data
2701 && $self->{role} eq 'server'
2702 && !$self->{quic}->ready
2703 ) {
2704 1 my $payload = substr($bytes, $prefix_length);
2705 1 my $length = length($payload);
2706  
2707 1 ▶ if (
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"datagram_buffered_count"} >= $self->{"max_buffered_datagrams"} or $self->{"datagram_buffered_bytes"} + $length > $self->{"max_buffered_datagram_bytes"}) 0 1 1
Condition33%1/3
$self->{"datagram_buffered_count"} >= $self->{"max_buffered_datagrams"} or $self->{"datagram_buffered_bytes"} + $length > $self->{"max_buffered_datagram_bytes"}
l!l&&r!l&&!r
001
MC/DC0%0/2
$self->{"datagram_buffered_count"} >= $self->{"max_buffered_datagrams"} or $self->{"datagram_buffered_bytes"} + $length > $self->{"max_buffered_datagram_bytes"}
$self->{"datagram_buffered_count"} >= $self->{"max_buffered_datagrams"} $self->{"datagram_buffered_bytes"} + $length > $self->{"max_buffered_datagram_bytes"}
Truth table33%1/3
A or B
A= $self->{"datagram_buffered_count"} >= $self->{"max_buffered_datagrams"}B= $self->{"datagram_buffered_bytes"} + $length > $self->{"max_buffered_datagram_bytes"}
ABresult
1X1
011
000
2708 $self->{datagram_buffered_count}
2709 >= $self->{max_buffered_datagrams}
2710 || $self->{datagram_buffered_bytes} + $length
2711 > $self->{max_buffered_datagram_bytes}
2712 ) {
2713 0 ++$self->{datagram_receive_drops};
2714 0 return;
2715 }
2716  
2717 1 ++$self->{datagram_buffered_count};
2718 1 $self->{datagram_buffered_bytes} += $length;
2719 1 push @{ $self->{pending_early_datagrams}{$id} }, $payload;
2720 1 return;
2721 }
2722  
2723 7 ▶ if (!$transaction->datagrams_enabled) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($transaction->datagrams_enabled) 1 6 7
2724 1 $self->_reject_datagram_stream(
2725 $transaction,
2726 'received HTTP Datagram for a request without datagram semantics',
2727 );
2728 1 return;
2729 }
2730  
2731 6 my $payload = substr($bytes, $prefix_length);
2732 6 $transaction->_receive_datagram($payload);
2733 6 return;
2734 }
2735  
2736 1 ▶sub _capsule_protocol_error {
Subroutine _capsule_protocol_error: called CC=7 SCAR=24.0
2737 1 my ($self, $transaction, $error) = @_;
2738  
2739 croak 'Capsule Protocol Transaction does not belong to this connection'
2740 unless blessed($transaction)
2741 && $transaction->isa('Unblock::HTTP3::Transaction')
2742 && defined($self->{transactions}{ $transaction->stream_id })
2743 1 ▶ && $self->{transactions}{ $transaction->stream_id } == $transaction;
Branch: 1 branch
BranchTrueFalseTotal
unless builtin::blessed($transaction) and $transaction->isa("Unblock::HTTP3::Transaction") and defined $self->{"transactions"}{$transaction->stream_id} and $self->{"transactions"}{$transaction->stream_id} == $transaction 0 1 1
Condition33%3/9
builtin::blessed($transaction) and $transaction->isa("Unblock::HTTP3::Transaction") and defined $self->{"transactions"}{$transaction->stream_id} and $self->{"transactions"}{$transaction->stream_id} == $transaction
!ll&&!rl&&r
001
builtin::blessed($transaction) and $transaction->isa("Unblock::HTTP3::Transaction") and defined $self->{"transactions"}{$transaction->stream_id}
!ll&&!rl&&r
001
builtin::blessed($transaction) and $transaction->isa("Unblock::HTTP3::Transaction")
!ll&&!rl&&r
001
MC/DC0%0/4
builtin::blessed($transaction) and $transaction->isa("Unblock::HTTP3::Transaction") and defined $self->{"transactions"}{$transaction->stream_id} and $self->{"transactions"}{$transaction->stream_id} == $transaction
builtin::blessed($transaction) $transaction->isa("Unblock::HTTP3::Transaction") defined $self->{"transactions"}{$transaction->stream_id} $self->{"transactions"}{$transaction->stream_id} == $transaction
Truth table20%1/5
A and B and C and D
A= builtin::blessed($transaction)B= $transaction->isa("Unblock::HTTP3::Transaction")C= defined $self->{"transactions"}{$transaction->stream_id}D= $self->{"transactions"}{$transaction->stream_id} == $transaction
ABCDresult
0XXX0
10XX0
110X0
11100
11111
2744  
2745 1 ▶ my $message = defined($error) && length("$error")
Branch: 1 branch
BranchTrueFalseTotal
defined $error && length "$error" ? : 1 0 1
Condition33%1/3
defined $error and length "$error"
!ll&&!rl&&r
001
MC/DC0%0/2
defined $error and length "$error"
defined $error length "$error"
Truth table33%1/3
A and B
A= defined $errorB= length "$error"
ABresult
0X0
100
111
2746 ? "$error"
2747 : 'malformed Capsule Protocol stream';
2748 1 $message =~ s/\s+\z//;
2749  
2750 1 $self->_reject_message_stream(
2751 $transaction->stream_id,
2752 "Capsule Protocol error: $message",
2753 );
2754  
2755 1 $transaction->_mark_error(
2756 "Capsule Protocol error: $message",
2757 );
2758  
2759 1 return;
2760 }
2761  
2762 2 ▶sub _reject_message_stream {
Subroutine _reject_message_stream: called CC=8 SCAR=21.3
2763 2 my ($self, $id, $reason) = @_;
2764  
2765 2 $self->{rejected_streams}{$id} = "$reason";
2766  
2767 2 my $stream = $self->{streams}{$id};
2768 2 my $transaction = $self->{transactions}{$id};
2769  
2770 2 ▶ if (defined $stream) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $stream) 2 0 2
2771 2 ▶ if ($stream->can_receive && !$stream->remote_finished) {
Branch: 1 branch
BranchTrueFalseTotal
if ($stream->can_receive and not $stream->remote_finished) 1 1 2
Condition66%2/3
$stream->can_receive and not $stream->remote_finished
!ll&&!rl&&r
011
MC/DC50%1/2
$stream->can_receive and not $stream->remote_finished
$stream->can_receive not $stream->remote_finished
Truth table66%2/3
A and not(B)
A= $stream->can_receiveB= not $stream->remote_finished
ABresult
0X0
100
111
2772 1 $self->{native}->shutdown_stream_read($id);
2773 1 $stream->stop_sending($H3_MESSAGE_ERROR);
2774 1 ▶ $transaction->_mark_local_stop_sending($H3_MESSAGE_ERROR)
Branch: 1 branch
BranchTrueFalseTotal
if defined $transaction 0 1 1
2775 if defined $transaction;
2776 }
2777  
2778 2 ▶ if ($stream->can_send && !defined($stream->local_reset_code)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($stream->can_send and not defined $stream->local_reset_code) 2 0 2
Condition33%1/3
$stream->can_send and not defined $stream->local_reset_code
!ll&&!rl&&r
002
MC/DC0%0/2
$stream->can_send and not defined $stream->local_reset_code
$stream->can_send not defined $stream->local_reset_code
Truth table33%1/3
A and not(B)
A= $stream->can_sendB= not defined $stream->local_reset_code
ABresult
0X0
100
111
2779 2 $self->{native}->shutdown_stream_write($id);
2780 2 $stream->reset($H3_MESSAGE_ERROR);
2781 2 ▶ $transaction->_mark_local_reset($H3_MESSAGE_ERROR)
Branch: 1 branch
BranchTrueFalseTotal
if defined $transaction 1 1 2
2782 if defined $transaction;
2783 }
2784 }
2785  
2786 2 $self->{native}->discard_body($id);
2787 2 $self->{native}->discard_header_block($id);
2788 2 return;
2789 }
2790  
2791 48 ▶sub _release_peer_bidi_stream_credit {
Subroutine _release_peer_bidi_stream_credit: called CC=7 SCAR=20.2
2792 48 my ($self, $id, $stream) = @_;
2793  
2794 48 ▶ return unless $self->{role} eq 'server';
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"role"} eq "server" 24 24 48
2795 24 ▶ return unless defined $stream;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $stream 0 24 24
2796 24 ▶ return if $stream->local_initiated;
Branch: 1 branch
BranchTrueFalseTotal
if $stream->local_initiated 0 24 24
2797 24 ▶ return unless $stream->bidirectional;
Branch: 1 branch
BranchTrueFalseTotal
unless $stream->bidirectional 0 24 24
2798  
2799 24 ▶ my $lifecycle = $self->{stream_lifecycle}{$id} ||= {};
Condition50%1/2
$self->{"stream_lifecycle"}{$id} ||= {}
l!l
240
MC/DC0%0/1
$self->{"stream_lifecycle"}{$id} ||= {}
$self->{"stream_lifecycle"}{$id}
Truth table50%1/2
A
A= $self->{"stream_lifecycle"}{$id}
Aresult
11
00
2800 24 ▶ return if $lifecycle->{peer_bidi_credit_released};
Branch: 1 branch
BranchTrueFalseTotal
if $lifecycle->{"peer_bidi_credit_released"} 0 24 24
2801  
2802 24 $lifecycle->{peer_bidi_credit_released} = 1;
2803 24 ++$self->{native_max_client_streams_bidi};
2804  
2805 $self->{native}->set_max_client_streams_bidi(
2806 $self->{native_max_client_streams_bidi},
2807 24 );
2808  
2809 24 return;
2810 }
2811  
2812 90 ▶sub _cleanup_stream_if_done {
Subroutine _cleanup_stream_if_done: called CC=5 SCAR=16.1
2813 90 my ($self, $id) = @_;
2814  
2815 90 my $lifecycle = $self->{stream_lifecycle}{$id};
2816 90 ▶ return unless defined($lifecycle) && $lifecycle->{closed_seen};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $lifecycle and $lifecycle->{"closed_seen"} 44 46 90
Condition66%2/3
defined $lifecycle and $lifecycle->{"closed_seen"}
!ll&&!rl&&r
04446
MC/DC50%1/2
defined $lifecycle and $lifecycle->{"closed_seen"}
defined $lifecycle $lifecycle->{"closed_seen"}
Truth table66%2/3
A and B
A= defined $lifecycleB= $lifecycle->{"closed_seen"}
ABresult
0X0
100
111
2817  
2818 46 my $transaction = $self->{transactions}{$id};
2819 46 ▶ return if defined($transaction) && !$transaction->is_terminal;
Branch: 1 branch
BranchTrueFalseTotal
if defined $transaction and not $transaction->is_terminal 0 46 46
Condition66%2/3
defined $transaction and not $transaction->is_terminal
!ll&&!rl&&r
1450
MC/DC0%0/2
defined $transaction and not $transaction->is_terminal
defined $transaction not $transaction->is_terminal
Truth table66%2/3
A and not(B)
A= defined $transactionB= not $transaction->is_terminal
ABresult
0X0
100
111
2820  
2821 46 delete $self->{streams}{$id};
2822 46 delete $self->{messages}{$id};
2823 46 delete $self->{outgoing}{$id};
2824 46 delete $self->{stream_lifecycle}{$id};
2825 46 delete $self->{trailer_field_section_size}{$id};
2826 46 delete $self->{output_finished}{$id};
2827 46 delete $self->{response_sent}{$id};
2828 46 delete $self->{body_bytes_sent}{$id};
2829 46 delete $self->{rejected_streams}{$id};
2830 46 delete $self->{peer_uni_probe}{$id};
2831 46 delete $self->{core_uni_streams}{$id};
2832 46 delete $self->{ignored_uni_streams}{$id};
2833 46 delete $self->{extension_stream_objects}{$id};
2834 46 delete $self->{transactions}{$id};
2835  
2836 46 return;
2837 }
2838  
2839 189 ▶sub _maybe_complete_transaction {
Subroutine _maybe_complete_transaction: called CC=15 SCAR=27.2
2840 189 my ($self, $id) = @_;
2841  
2842 189 my $transaction = $self->{transactions}{$id};
2843 189 ▶ return unless defined $transaction;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $transaction 16 173 189
2844 173 ▶ return if $transaction->is_terminal;
Branch: 1 branch
BranchTrueFalseTotal
if $transaction->is_terminal 16 157 173
2845  
2846 157 ▶ if ($self->{role} eq 'client') {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"role"} eq "client") 88 69 157
2847 88 my $response = $transaction->response;
2848 88 ▶ return unless defined $response;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $response 42 46 88
2849 46 ▶ return unless $response->is_complete;
Branch: 1 branch
BranchTrueFalseTotal
unless $response->is_complete 24 22 46
2850  
2851 22 my $reader = $transaction->_incoming_body_reader('response');
2852 22 ▶ return if defined($reader) && !$reader->is_complete;
Branch: 1 branch
BranchTrueFalseTotal
if defined $reader and not $reader->is_complete 0 22 22
Condition66%2/3
defined $reader and not $reader->is_complete
!ll&&!rl&&r
1570
MC/DC0%0/2
defined $reader and not $reader->is_complete
defined $reader not $reader->is_complete
Truth table66%2/3
A and not(B)
A= defined $readerB= not $reader->is_complete
ABresult
0X0
100
111
2853  
2854 22 ▶ if ($transaction->request->method eq 'CONNECT') {
Branch: 1 branch
BranchTrueFalseTotal
if ($transaction->request->method eq "CONNECT") 5 17 22
2855 5 my $writer = $transaction->_request_body_object;
2856 5 ▶ return unless defined($writer) && $writer->is_complete;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $writer and $writer->is_complete 0 5 5
Condition33%1/3
defined $writer and $writer->is_complete
!ll&&!rl&&r
005
MC/DC0%0/2
defined $writer and $writer->is_complete
defined $writer $writer->is_complete
Truth table33%1/3
A and B
A= defined $writerB= $writer->is_complete
ABresult
0X0
100
111
2857 }
2858  
2859 22 $transaction->_mark_complete;
2860 22 $self->_cleanup_stream_if_done($id);
2861 22 return;
2862 }
2863  
2864 69 my $request = $transaction->request;
2865 69 ▶ return unless $request->is_complete;
Branch: 1 branch
BranchTrueFalseTotal
unless $request->is_complete 22 47 69
2866  
2867 47 my $reader = $transaction->_incoming_body_reader('request');
2868 47 ▶ return if defined($reader) && !$reader->is_complete;
Branch: 1 branch
BranchTrueFalseTotal
if defined $reader and not $reader->is_complete 1 46 47
Condition100%3/3
defined $reader and not $reader->is_complete
!ll&&!rl&&r
35111
MC/DC100%2/2
defined $reader and not $reader->is_complete
defined $reader not $reader->is_complete
Truth table100%3/3
A and not(B)
A= defined $readerB= not $reader->is_complete
ABresult
0X0
100
111
2869  
2870 46 ▶ return unless $self->{output_finished}{$id};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"output_finished"}{$id} 24 22 46
2871  
2872 22 $transaction->_mark_complete;
2873 22 $self->_cleanup_stream_if_done($id);
2874 22 return;
2875 }
2876  
2877 0 ▶sub shutdown_notice_sent {
Subroutine shutdown_notice_sent: not called CC=3 SCAR=24.8
Pod undocumented
2878 0 my ($self, @args) = @_;
2879 0 ▶ croak 'shutdown_notice_sent() does not accept arguments' if @args;
Branch: 1 branch
BranchTrueFalseTotal
if @args 0 0 0
2880 0 ▶ return $self->{shutdown_notice_sent} ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$self->{'shutdown_notice_sent'} ? : 0 0 0
2881 }
2882  
2883 0 ▶sub shutdown_started {
Subroutine shutdown_started: not called CC=3 SCAR=24.8
Pod undocumented
2884 0 my ($self, @args) = @_;
2885 0 ▶ croak 'shutdown_started() does not accept arguments' if @args;
Branch: 1 branch
BranchTrueFalseTotal
if @args 0 0 0
2886 0 ▶ return $self->{shutdown_started} ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$self->{'shutdown_started'} ? : 0 0 0
2887 }
2888  
2889 0 ▶sub remote_shutdown_id {
Subroutine remote_shutdown_id: not called CC=2 SCAR=17.9
Pod undocumented
2890 0 my ($self, @args) = @_;
2891 0 ▶ croak 'remote_shutdown_id() does not accept arguments' if @args;
Branch: 1 branch
BranchTrueFalseTotal
if @args 0 0 0
2892 0 return $self->{remote_shutdown_id};
2893 }
2894  
2895 0 ▶sub shutdown_notice {
Subroutine shutdown_notice: not called CC=4 SCAR=30.0
Pod undocumented
2896 0 my ($self) = @_;
2897  
2898 croak 'HTTP/3 connection has not been started'
2899 0 ▶ unless $self->{started};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"started"} 0 0 0
2900 croak 'HTTP/3 connection has failed'
2901 0 ▶ if $self->{failed};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"failed"} 0 0 0
2902  
2903 0 ▶ return $self if $self->{shutdown_notice_sent};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"shutdown_notice_sent"} 0 0 0
2904  
2905 0 $self->{native}->submit_shutdown_notice;
2906 0 $self->{shutdown_notice_sent} = 1;
2907 0 $self->_drain_output;
2908  
2909 0 return $self;
2910 }
2911  
2912 0 ▶sub shutdown {
Subroutine shutdown: not called CC=4 SCAR=30.0
Pod undocumented
2913 0 my ($self) = @_;
2914  
2915 croak 'HTTP/3 connection has not been started'
2916 0 ▶ unless $self->{started};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"started"} 0 0 0
2917 croak 'HTTP/3 connection has failed'
2918 0 ▶ if $self->{failed};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"failed"} 0 0 0
2919  
2920 0 ▶ return $self if $self->{shutdown_started};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"shutdown_started"} 0 0 0
2921  
2922 0 $self->{native}->begin_shutdown;
2923 0 $self->{shutdown_started} = 1;
2924 0 $self->_drain_output;
2925  
2926 0 return $self;
2927 }
2928  
2929 0 ▶sub drained {
Subroutine drained: not called CC=4 SCAR=30.0
Pod undocumented
2930 0 my ($self, @args) = @_;
2931  
2932 0 ▶ croak 'drained() does not accept arguments' if @args;
Branch: 1 branch
BranchTrueFalseTotal
if @args 0 0 0
2933 croak 'drained() is only meaningful for a server HTTP/3 connection'
2934 0 ▶ unless $self->{role} eq 'server';
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"role"} eq "server" 0 0 0
2935  
2936 0 ▶ return $self->{native}->is_drained ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$self->{'native'}->is_drained ? : 0 0 0
2937 }
2938  
2939 19 ▶sub _bind_local_streams {
Subroutine _bind_local_streams: called CC=6 SCAR=18.9
2940 19 my ($self) = @_;
2941  
2942 19 ▶ return 1 if defined $self->{control_stream_id};
Branch: 1 branch
BranchTrueFalseTotal
if defined $self->{"control_stream_id"} 0 19 19
2943  
2944 19 my $control = $self->{quic}->open_uni_stream;
2945 19 my $qenc = $self->{quic}->open_uni_stream;
2946 19 my $qdec = $self->{quic}->open_uni_stream;
2947  
2948 19 ▶ croak 'peer did not permit the three required HTTP/3 unidirectional streams'
Branch: 1 branch
BranchTrueFalseTotal
unless defined $control and defined $qenc and defined $qdec 0 19 19
Condition33%2/6
defined $control and defined $qenc and defined $qdec
!ll&&!rl&&r
0019
defined $control and defined $qenc
!ll&&!rl&&r
0019
MC/DC0%0/3
defined $control and defined $qenc and defined $qdec
defined $control defined $qenc defined $qdec
Truth table25%1/4
A and B and C
A= defined $controlB= defined $qencC= defined $qdec
ABCresult
0XX0
10X0
1100
1111
2949 unless defined($control) && defined($qenc) && defined($qdec);
2950  
2951 19 for my $stream ($control, $qenc, $qdec) {
2952 57 $self->{streams}{ $stream->id } = $stream;
2953 }
2954  
2955 $self->{native}->bind_streams(
2956 19 $control->id,
2957 $qenc->id,
2958 $qdec->id,
2959 );
2960  
2961 19 $self->{control_stream_id} = $control->id;
2962 19 $self->{qpack_encoder_stream_id} = $qenc->id;
2963 19 $self->{qpack_decoder_stream_id} = $qdec->id;
2964 19 return 1;
2965 }
2966  
2967 19 ▶sub start {
Subroutine start: called CC=15 SCAR=29.0
Pod undocumented
2968 19 my ($self) = @_;
2969  
2970 19 ▶ if ($self->{started}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"started"}) 0 19 19
2971 0 $self->_sync_early_data_status;
2972 0 return $self;
2973 }
2974  
2975 19 ▶ my $ready = $self->{quic}->ready ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$self->{'quic'}->ready ? : 16 3 19
2976 19 my $early_status = $self->{quic}->early_data_status;
2977  
2978 19 ▶ if (!$ready) {
Branch: 2 branches
BranchTrueFalseTotal
if (not $ready) { } 3 16 19
elsif ($self->{'role'} eq 'server' and $early_status eq 'accepted' and not defined $self->{'remembered_local_settings'}) { } 0 32 32
2979 3 ▶ if ($self->{role} eq 'client') {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'role'} eq 'client') { } 2 1 3
2980 croak 'cannot start HTTP/3 0-RTT without remembered_peer_settings'
2981 2 ▶ unless defined $self->{remembered_peer_settings};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->{"remembered_peer_settings"} 0 2 2
2982 2 ▶ croak "cannot start HTTP/3 before QUIC is ready unless 0-RTT is pending"
Branch: 1 branch
BranchTrueFalseTotal
unless $early_status eq "pending" 0 2 2
2983 unless $early_status eq 'pending';
2984 } else {
2985 croak 'cannot start HTTP/3 server before QUIC is ready without remembered_local_settings'
2986 1 ▶ unless defined $self->{remembered_local_settings};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->{"remembered_local_settings"} 0 1 1
2987 }
2988  
2989 3 $self->{early_data_started} = 1;
2990 ▶ } elsif (
Condition50%3/6
$self->{"role"} eq "server" and $early_status eq "accepted" and not defined $self->{"remembered_local_settings"}
!ll&&!rl&&r
1600
$self->{"role"} eq "server" and $early_status eq "accepted"
!ll&&!rl&&r
790
MC/DC0%0/3
$self->{"role"} eq "server" and $early_status eq "accepted" and not defined $self->{"remembered_local_settings"}
$self->{"role"} eq "server" $early_status eq "accepted" not defined $self->{"remembered_local_settings"}
Truth table50%2/4
A and B and not(C)
A= $self->{"role"} eq "server"B= $early_status eq "accepted"C= not defined $self->{"remembered_local_settings"}
ABCresult
0XX0
10X0
1100
1111
2991 $self->{role} eq 'server'
2992 && $early_status eq 'accepted'
2993 && !defined($self->{remembered_local_settings})
2994 ) {
2995 0 croak 'accepted QUIC 0-RTT requires remembered_local_settings for HTTP/3';
2996 }
2997  
2998 19 ▶ if (!defined $self->{quic}->send_buffer_limit) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $self->{"quic"}->send_buffer_limit) 18 1 19
2999 18 $self->{quic}->send_buffer_limit($self->{send_buffer_limit});
3000 }
3001  
3002 # A client sending 0-RTT must send its control and QPACK streams in early
3003 # data. A server can receive and parse early request/control streams before
3004 # handshake completion, but its own HTTP/3 streams use 1-RTT and are bound
3005 # once the QUIC connection becomes ready.
3006 19 ▶ if ($ready || $self->{role} eq 'client') {
Branch: 1 branch
BranchTrueFalseTotal
if ($ready or $self->{"role"} eq "client") 18 1 19
Condition100%3/3
$ready or $self->{"role"} eq "client"
l!l&&r!l&&!r
1621
MC/DC100%2/2
$ready or $self->{"role"} eq "client"
$ready $self->{"role"} eq "client"
Truth table100%3/3
A or B
A= $readyB= $self->{"role"} eq "client"
ABresult
1X1
011
000
3007 18 $self->_bind_local_streams;
3008 }
3009  
3010 19 $self->{started} = 1;
3011  
3012 19 my $weak = $self;
3013 19 weaken($weak);
3014  
3015 381 ▶ $self->{quic}->on_stream_activity(sub {
Subroutine __ANON__: called CC=2 SCAR=7.2
3016 381 ▶ return unless defined $weak;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $weak 0 381 381
3017 381 $weak->_service;
3018 19 });
3019  
3020 0 ▶ $self->{quic}->on_stream_available(sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
3021 0 ▶ return unless defined $weak;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $weak 0 0 0
3022 0 $weak->_service;
3023 19 });
3024  
3025 19 ▶ if ($self->{quic}->can_receive_datagram) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"quic"}->can_receive_datagram) 9 10 19
3026 9 ▶ $self->{quic}->on_datagram(sub {
Subroutine __ANON__: called CC=2 SCAR=7.1
3027 9 my ($quic, $bytes, $early_data) = @_;
3028 9 ▶ return unless defined $weak;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $weak 0 9 9
3029 9 $weak->_receive_quic_datagram($bytes, $early_data);
3030 9 });
3031 }
3032  
3033 19 $self->_service;
3034  
3035 19 return $self;
3036 }
3037  
3038 1 ▶sub _reset_peer_settings_to_defaults {
Subroutine _reset_peer_settings_to_defaults: called CC=1 SCAR=0.0
3039 1 my ($self) = @_;
3040  
3041 1 $self->{peer_max_field_section_size} = $HTTP3_MAX_VARINT;
3042 1 $self->{peer_enable_connect_protocol} = 0;
3043 1 $self->{peer_h3_datagram} = 0;
3044 1 $self->{peer_extension_settings} = {};
3045 1 $self->{peer_settings_wire} = {};
3046 1 $self->{peer_settings_received} = 0;
3047 1 $self->{peer_settings_initialized} = 0;
3048 1 $self->{pending_peer_settings} = undef;
3049 1 $self->{pending_peer_extension_settings} = undef;
3050 1 $self->{peer_settings_parser} = {};
3051 1 return;
3052 }
3053  
3054 1 ▶sub _rollback_rejected_early_data {
Subroutine _rollback_rejected_early_data: called CC=8 SCAR=20.9
3055 1 my ($self) = @_;
3056  
3057 1 ▶ return if $self->{early_data_rollback_done};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"early_data_rollback_done"} 0 1 1
3058 1 ▶ return unless $self->{role} eq 'client';
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"role"} eq "client" 0 1 1
3059 1 ▶ return unless $self->{early_data_started};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"early_data_started"} 0 1 1
3060 1 ▶ return unless $self->{quic}->early_data_status eq 'rejected';
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"quic"}->early_data_status eq "rejected" 0 1 1
3061 1 ▶ return unless $self->{quic}->ready;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"quic"}->ready 0 1 1
3062  
3063 1 for my $transaction (values %{ $self->{transactions} }) {
3064 1 ▶ next if $transaction->is_terminal;
Branch: 1 branch
BranchTrueFalseTotal
if $transaction->is_terminal 0 1 1
3065 1 $transaction->_mark_error(
3066 'QUIC 0-RTT was rejected; retry the request only if it is replay-safe',
3067 );
3068 }
3069  
3070 1 $self->{transactions} = {};
3071 1 $self->{ready_transactions} = [];
3072 1 $self->{pending_early_transactions} = [];
3073 1 $self->{pending_early_datagrams} = {};
3074 1 $self->{ready_informational} = [];
3075 1 $self->{streams} = {};
3076 1 $self->{messages} = {};
3077 1 $self->{outgoing} = {};
3078 1 $self->{stream_lifecycle} = {};
3079 1 $self->{trailer_field_section_size} = {};
3080 1 $self->{output_finished} = {};
3081 1 $self->{response_sent} = {};
3082 1 $self->{body_bytes_sent} = {};
3083 1 $self->{rejected_streams} = {};
3084 1 $self->{peer_uni_probe} = {};
3085 1 $self->{core_uni_streams} = {};
3086 1 $self->{ignored_uni_streams} = {};
3087 1 $self->{extension_stream_objects} = {};
3088 1 $self->{control_settings_rewritten} = 0;
3089 1 $self->{control_settings_delta} = 0;
3090 1 $self->{control_settings_pending} = undef;
3091 1 delete $self->{control_stream_id};
3092 1 delete $self->{qpack_encoder_stream_id};
3093 1 delete $self->{qpack_decoder_stream_id};
3094  
3095 $self->{native} = Unblock::HTTP3::_Native->client(
3096 $self->{max_field_section_size},
3097 $self->{qpack_max_table_capacity},
3098 $self->{qpack_blocked_streams},
3099 0,
3100 $self->{enable_http_datagrams},
3101 1 );
3102  
3103 1 $self->_reset_peer_settings_to_defaults;
3104  
3105 1 $self->{started} = 0;
3106 1 $self->{early_data_started} = 0;
3107 1 $self->{early_data_rollback_done} = 1;
3108 1 $self->{early_data_status} = 'rejected';
3109  
3110 1 $self->start;
3111 1 return 1;
3112 }
3113  
3114 0 ▶sub _discard_pending_early_datagrams {
Subroutine _discard_pending_early_datagrams: not called CC=3 SCAR=24.8
3115 0 my ($self, $id) = @_;
3116  
3117 0 my $pending = delete $self->{pending_early_datagrams}{$id};
3118 0 ▶ return unless defined $pending;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $pending 0 0 0
3119  
3120 0 for my $bytes (@$pending) {
3121 0 $self->_datagram_dequeued(length($bytes));
3122 }
3123  
3124 0 return;
3125 }
3126  
3127 278 ▶sub _promote_accepted_early_transactions {
Subroutine _promote_accepted_early_transactions: called CC=17 SCAR=33.6
3128 278 my ($self) = @_;
3129  
3130 278 ▶ return unless $self->{role} eq 'server';
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"role"} eq "server" 0 278 278
3131 278 ▶ return unless $self->{quic}->ready;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"quic"}->ready 0 278 278
3132 278 ▶ return if $self->{quic}->early_data_status eq 'rejected';
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"quic"}->early_data_status eq "rejected" 0 278 278
3133 278 ▶ return unless @{ $self->{pending_early_transactions} };
Branch: 1 branch
BranchTrueFalseTotal
unless @{$self->{"pending_early_transactions"};} 277 1 278
3134  
3135 my @pending =
3136 1 splice @{ $self->{pending_early_transactions} };
3137  
3138 1 for my $transaction (@pending) {
3139 1 ▶ next if $transaction->is_terminal;
Branch: 1 branch
BranchTrueFalseTotal
if $transaction->is_terminal 0 1 1
3140  
3141 1 my $datagrams = 0;
3142 1 ▶ if (defined $self->{datagram_request}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->{"datagram_request"}) 1 0 1
3143 $datagrams =
3144 1 ▶ $self->{datagram_request}->(
Branch: 1 branch
BranchTrueFalseTotal
$self->{'datagram_request'}->($self, $transaction->request) ? : 1 0 1
3145 $self,
3146 $transaction->request,
3147 ) ? 1 : 0;
3148 }
3149  
3150 1 ▶ $transaction->_enable_datagrams if $datagrams;
Branch: 1 branch
BranchTrueFalseTotal
if $datagrams 1 0 1
3151  
3152 1 my $id = $transaction->stream_id;
3153 1 my $queued = delete $self->{pending_early_datagrams}{$id};
3154  
3155 1 ▶ if (defined $queued && @$queued) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $queued and @$queued) 1 0 1
Condition33%1/3
defined $queued and @$queued
!ll&&!rl&&r
001
MC/DC0%0/2
defined $queued and @$queued
defined $queued @$queued
Truth table33%1/3
A and B
A= defined $queuedB= @$queued
ABresult
0X0
100
111
3156 1 ▶ if (!$datagrams) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($datagrams) 0 1 1
3157 0 for my $bytes (@$queued) {
3158 0 $self->_datagram_dequeued(length($bytes));
3159 }
3160  
3161 $self->_reject_datagram_stream(
3162 0 $transaction,
3163 'received HTTP Datagram for a request without datagram semantics',
3164 );
3165 0 next;
3166 }
3167  
3168 1 for my $bytes (@$queued) {
3169 1 $self->_datagram_dequeued(length($bytes));
3170 1 $transaction->_receive_datagram($bytes);
3171 }
3172 }
3173  
3174 1 push @{ $self->{ready_transactions} }, $transaction;
3175  
3176 1 ▶ if (defined $self->{callbacks}{on_request}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->{"callbacks"}{"on_request"}) 0 1 1
3177 0 my $result = $transaction->_invoke(
3178 'on_request',
3179 $transaction->request,
3180 );
3181 0 ▶ die $result unless $result eq '1';
Branch: 1 branch
BranchTrueFalseTotal
unless $result eq 1 0 0 0
3182 }
3183 }
3184  
3185 1 return 1;
3186 }
3187  
3188 0 ▶sub _reject_pending_early_transactions {
Subroutine _reject_pending_early_transactions: not called CC=5 SCAR=34.0
3189 0 my ($self) = @_;
3190  
3191 0 ▶ return unless $self->{role} eq 'server';
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"role"} eq "server" 0 0 0
3192 0 ▶ return unless @{ $self->{pending_early_transactions} };
Branch: 1 branch
BranchTrueFalseTotal
unless @{$self->{"pending_early_transactions"};} 0 0 0
3193  
3194 my @pending =
3195 0 splice @{ $self->{pending_early_transactions} };
3196  
3197 0 for my $transaction (@pending) {
3198 0 my $id = $transaction->stream_id;
3199 0 $self->_discard_pending_early_datagrams($id);
3200  
3201 0 ▶ $transaction->_mark_error(
Branch: 1 branch
BranchTrueFalseTotal
unless $transaction->is_terminal 0 0 0
3202 'QUIC rejected 0-RTT before HTTP request processing',
3203 ) unless $transaction->is_terminal;
3204 }
3205  
3206 0 return 1;
3207 }
3208  
3209 535 ▶sub _sync_early_data_status {
Subroutine _sync_early_data_status: called CC=7 SCAR=19.5
3210 535 my ($self) = @_;
3211  
3212 535 my $status = $self->{quic}->early_data_status;
3213 535 my $previous = $self->{early_data_status};
3214 535 $self->{early_data_status} = $status;
3215  
3216 535 ▶ if (
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"role"} eq "client" and $self->{"early_data_started"} and $status eq "rejected") 1 534 535
Condition100%6/6
$self->{"role"} eq "client" and $self->{"early_data_started"} and $status eq "rejected"
!ll&&!rl&&r
521131
$self->{"role"} eq "client" and $self->{"early_data_started"}
!ll&&!rl&&r
29722414
MC/DC100%3/3
$self->{"role"} eq "client" and $self->{"early_data_started"} and $status eq "rejected"
$self->{"role"} eq "client" $self->{"early_data_started"} $status eq "rejected"
Truth table100%4/4
A and B and C
A= $self->{"role"} eq "client"B= $self->{"early_data_started"}C= $status eq "rejected"
ABCresult
0XX0
10X0
1100
1111
3217 $self->{role} eq 'client'
3218 && $self->{early_data_started}
3219 && $status eq 'rejected'
3220 ) {
3221 1 return $self->_rollback_rejected_early_data;
3222 }
3223  
3224 534 ▶ if ($self->{role} eq 'server') {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"role"} eq "server") 297 237 534
3225 297 ▶ if ($status eq 'rejected') {
Branch: 2 branches
BranchTrueFalseTotal
if ($status eq 'rejected') { } 0 297 297
elsif ($self->{'quic'}->ready) { } 278 19 297
3226 0 $self->_reject_pending_early_transactions;
3227 } elsif ($self->{quic}->ready) {
3228 278 $self->_promote_accepted_early_transactions;
3229 }
3230 }
3231  
3232 534 return 0;
3233 }
3234  
3235 224 ▶sub _now_ns {
Subroutine _now_ns: called CC=1 SCAR=0.0
3236 return int(
3237 224 Time::HiRes::clock_gettime(Time::HiRes::CLOCK_MONOTONIC())
3238 * 1_000_000_000
3239 );
3240 }
3241  
3242 504 ▶sub _service {
Subroutine _service: called CC=20 SCAR=31.0
3243 504 my ($self) = @_;
3244  
3245 504 ▶ return unless $self->{started};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"started"} 0 504 504
3246 504 ▶ return if $self->{failed};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"failed"} 0 504 504
3247  
3248 504 my $restarted = $self->_sync_early_data_status;
3249 return if !$self->{quic}->ready
3250 504 ▶ && $self->{quic}->early_data_status eq 'rejected';
Branch: 1 branch
BranchTrueFalseTotal
if not $self->{"quic"}->ready and $self->{"quic"}->early_data_status eq "rejected" 0 504 504
Condition66%2/3
not $self->{"quic"}->ready and $self->{"quic"}->early_data_status eq "rejected"
!ll&&!rl&&r
483210
MC/DC0%0/2
not $self->{"quic"}->ready and $self->{"quic"}->early_data_status eq "rejected"
not $self->{"quic"}->ready $self->{"quic"}->early_data_status eq "rejected"
Truth table66%2/3
not(A) and B
A= not $self->{"quic"}->readyB= $self->{"quic"}->early_data_status eq "rejected"
ABresult
0X0
100
111
3251 504 ▶ return if $restarted;
Branch: 1 branch
BranchTrueFalseTotal
if $restarted 0 504 504
3252  
3253 504 ▶ if (
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"role"} eq "server" and $self->{"quic"}->ready and not defined $self->{"control_stream_id"}) 1 503 504
Condition100%6/6
$self->{"role"} eq "server" and $self->{"quic"}->ready and not defined $self->{"control_stream_id"}
!ll&&!rl&&r
2262771
$self->{"role"} eq "server" and $self->{"quic"}->ready
!ll&&!rl&&r
20719278
MC/DC100%3/3
$self->{"role"} eq "server" and $self->{"quic"}->ready and not defined $self->{"control_stream_id"}
$self->{"role"} eq "server" $self->{"quic"}->ready not defined $self->{"control_stream_id"}
Truth table100%4/4
A and B and not(C)
A= $self->{"role"} eq "server"B= $self->{"quic"}->readyC= not defined $self->{"control_stream_id"}
ABCresult
0XX0
10X0
1100
1111
3254 $self->{role} eq 'server'
3255 && $self->{quic}->ready
3256 && !defined($self->{control_stream_id})
3257 ) {
3258 1 $self->_bind_local_streams;
3259 }
3260  
3261 504 ▶ if ($self->{servicing}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"servicing"}) 0 504 504
3262 0 $self->{service_again} = 1;
3263 0 return;
3264 }
3265  
3266 504 $self->{servicing} = 1;
3267  
3268 504 my $ok = eval {
3269 do {
3270 504 $self->{service_again} = 0;
3271  
3272 504 my @new_ids;
3273  
3274 504 ▶ while (my $stream = $self->{quic}->next_stream) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $stream = $self->{"quic"}->next_stream) 69 504 573
3275 69 $self->{streams}{ $stream->id } = $stream;
3276 69 push @new_ids, $stream->id;
3277 }
3278  
3279 504 for my $id (@new_ids) {
3280 69 ▶ last if $self->{failed};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"failed"} 0 69 69
3281 69 $self->_service_stream($id);
3282 }
3283  
3284 504 ▶ while (
Branch: 1 branch
BranchTrueFalseTotal
if (not $self->{"failed"} and defined(my $id = $self->{"quic"}->next_active_stream_id)) 436 504 940
Condition100%3/3
not $self->{"failed"} and defined(my $id = $self->{"quic"}->next_active_stream_id)
!ll&&!rl&&r
7497436
MC/DC100%2/2
not $self->{"failed"} and defined(my $id = $self->{"quic"}->next_active_stream_id)
not $self->{"failed"} defined(my $id = $self->{"quic"}->next_active_stream_id)
Truth table100%3/3
not(A) and B
A= not $self->{"failed"}B= defined(my $id = $self->{"quic"}->next_active_stream_id)
ABresult
0X0
100
111
3285 !$self->{failed}
3286 && defined(my $id = $self->{quic}->next_active_stream_id)
3287 ) {
3288 436 $self->_service_stream($id);
3289 }
3290  
3291 504 ▶ if (!$self->{failed}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"failed"}) 497 7 504
3292 497 $self->_drain_events;
3293 $self->_drain_output
3294 497 ▶ if defined $self->{control_stream_id};
Branch: 1 branch
BranchTrueFalseTotal
if defined $self->{"control_stream_id"} 478 19 497
3295 }
3296 504 ▶ } while ($self->{service_again} && !$self->{failed});
Branch: 1 branch
BranchTrueFalseTotal
$self->{"service_again"} and not $self->{"failed"} and do { do { $self->{"service_again"} = 0; my @new_ids; while (my $stream = $self->{"quic"}->next_stream) { do { $self->{"streams"}{$stream->id} = $stream; push @new_ids, $stream->id }; } ; foreach my $id (@new_ids) { last if $self->{"failed"}; $self->_service_stream($id); } ; while (not $self->{"failed"} and defined(my $id = $self->{"quic"}->next_active_stream_id)) { do { $self->_service_stream($id) }; } ; unless ($self->{"failed"}) { $self->_drain_events; $self->_drain_output if defined $self->{"control_stream_id"}; } } } 0 504 504
Condition33%1/3
$self->{"service_again"} and not $self->{"failed"}
!ll&&!rl&&r
50400
MC/DC0%0/2
$self->{"service_again"} and not $self->{"failed"}
$self->{"service_again"} not $self->{"failed"}
Truth table33%1/3
A and not(B)
A= $self->{"service_again"}B= not $self->{"failed"}
ABresult
0X0
100
111
3297  
3298 504 1;
3299 };
3300  
3301 504 my $error = $@;
3302 504 $self->{servicing} = 0;
3303  
3304 504 ▶ die $error unless $ok;
Branch: 1 branch
BranchTrueFalseTotal
unless $ok 0 504 504
3305 504 return;
3306 }
3307  
3308 4 ▶sub _service_ignored_uni_stream {
Subroutine _service_ignored_uni_stream: called CC=5 SCAR=16.1
3309 4 my ($self, $id, $stream) = @_;
3310  
3311 4 ▶ if ($stream->can_receive) {
Branch: 1 branch
BranchTrueFalseTotal
if ($stream->can_receive) 4 0 4
3312 4 ▶ while (my $chunk = $stream->next_data_chunk) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $chunk = $stream->next_data_chunk) 2 4 6
3313 2 my ($bytes) = @$chunk;
3314 2 ▶ $stream->consume(length($bytes))
Branch: 1 branch
BranchTrueFalseTotal
if length $bytes 1 1 2
3315 if length($bytes);
3316 }
3317 }
3318  
3319 4 ▶ if ($stream->closed) {
Branch: 1 branch
BranchTrueFalseTotal
if ($stream->closed) 1 3 4
3320 1 delete $self->{streams}{$id};
3321 1 delete $self->{ignored_uni_streams}{$id};
3322 1 delete $self->{peer_uni_probe}{$id};
3323 }
3324  
3325 4 return;
3326 }
3327  
3328 14 ▶sub _service_extension_stream {
Subroutine _service_extension_stream: called CC=6 SCAR=18.0
3329 14 my ($self, $id, $stream, $extension) = @_;
3330  
3331 14 ▶ if ($stream->can_receive) {
Branch: 1 branch
BranchTrueFalseTotal
if ($stream->can_receive) 8 6 14
3332 8 $extension->_drain_receive;
3333 }
3334  
3335 14 ▶ if ($stream->can_send) {
Branch: 1 branch
BranchTrueFalseTotal
if ($stream->can_send) 6 8 14
3336 6 $extension->_drain_send;
3337 }
3338  
3339 14 my $remote_reset = $stream->remote_reset_code;
3340 14 ▶ $extension->_mark_reset($remote_reset)
Branch: 1 branch
BranchTrueFalseTotal
if defined $remote_reset 0 14 14
3341 if defined $remote_reset;
3342  
3343 14 my $remote_stop = $stream->remote_stop_sending_code;
3344 14 ▶ $extension->_mark_stop($remote_stop)
Branch: 1 branch
BranchTrueFalseTotal
if defined $remote_stop 0 14 14
3345 if defined $remote_stop;
3346  
3347 14 ▶ if ($stream->closed) {
Branch: 1 branch
BranchTrueFalseTotal
if ($stream->closed) 5 9 14
3348 5 delete $self->{streams}{$id};
3349 5 delete $self->{extension_stream_objects}{$id};
3350 5 delete $self->{peer_uni_probe}{$id};
3351 }
3352  
3353 14 return;
3354 }
3355  
3356 40 ▶sub _classify_peer_uni_stream {
Subroutine _classify_peer_uni_stream: called CC=22 SCAR=37.1
3357 40 my ($self, $id, $stream) = @_;
3358  
3359 40 ▶ my $state = $self->{peer_uni_probe}{$id} ||= {
Condition50%1/2
$self->{"peer_uni_probe"}{$id} ||= {"buffer", "", "fin", 0}
l!l
400
MC/DC0%0/1
$self->{"peer_uni_probe"}{$id} ||= {"buffer", "", "fin", 0}
$self->{"peer_uni_probe"}{$id}
Truth table50%1/2
A
A= $self->{"peer_uni_probe"}{$id}
Aresult
11
00
3360 buffer => '',
3361 fin => 0,
3362 };
3363  
3364 40 while (1) {
3365 my ($type, $type_length) =
3366 80 _decode_http3_varint($state->{buffer}, 0);
3367  
3368 80 ▶ if (defined $type) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $type) 40 40 80
3369 40 ▶ if ($self->{role} eq 'client' && $type eq '1') {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"role"} eq "client" and $type eq 1) 1 39 40
Condition100%3/3
$self->{"role"} eq "client" and $type eq 1
!ll&&!rl&&r
22171
MC/DC100%2/2
$self->{"role"} eq "client" and $type eq 1
$self->{"role"} eq "client" $type eq 1
Truth table100%3/3
A and B
A= $self->{"role"} eq "client"B= $type eq 1
ABresult
0X0
100
111
3370 $stream->consume(length($state->{buffer}))
3371 1 ▶ if length($state->{buffer});
Branch: 1 branch
BranchTrueFalseTotal
if length $state->{"buffer"} 1 0 1
3372  
3373 1 delete $self->{peer_uni_probe}{$id};
3374  
3375 1 $self->_fail_connection(
3376 $H3_ID_ERROR,
3377 'peer opened a push stream without advertised push capacity',
3378 );
3379  
3380 1 return 'failed';
3381 }
3382  
3383 39 ▶ if ($CORE_STREAM_TYPE{$type}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($CORE_STREAM_TYPE{$type}) 36 3 39
3384 36 my $bytes = $state->{buffer};
3385 36 my $fin = $state->{fin};
3386  
3387 36 delete $self->{peer_uni_probe}{$id};
3388 36 $self->{core_uni_streams}{$id} = 1;
3389  
3390 36 $self->_inspect_peer_settings_bytes($id, $bytes);
3391 36 ▶ return 'failed' if $self->{failed};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"failed"} 1 35 36
3392  
3393 my $result = $self->{native}->read_stream(
3394 35 ▶ $id,
Branch: 1 branch
BranchTrueFalseTotal
$fin ? : 0 35 35
3395 $bytes,
3396 $fin ? 1 : 0,
3397 _now_ns(),
3398 );
3399  
3400 35 ▶ if (@$result > 1) {
Branch: 1 branch
BranchTrueFalseTotal
if (@$result > 1) 0 35 35
3401 0 my ($unused, $lib_error, $app_error, $detail) = @$result;
3402  
3403 0 $self->_fail_connection(
3404 $app_error,
3405 "libnghttp3 read error: $detail ($lib_error)",
3406 );
3407  
3408 0 return 'failed';
3409 }
3410  
3411 35 my $consumed = $result->[0];
3412 35 ▶ $stream->consume($consumed) if $consumed;
Branch: 1 branch
BranchTrueFalseTotal
if $consumed 35 0 35
3413 35 $self->_drain_events;
3414  
3415 35 return 'core';
3416 }
3417  
3418 3 ▶ if (_is_grease_stream_type($type)) {
Branch: 1 branch
BranchTrueFalseTotal
if (_is_grease_stream_type($type)) 0 3 3
3419 $stream->consume(length($state->{buffer}))
3420 0 ▶ if length($state->{buffer});
Branch: 1 branch
BranchTrueFalseTotal
if length $state->{"buffer"} 0 0 0
3421  
3422 0 delete $self->{peer_uni_probe}{$id};
3423 0 $self->{ignored_uni_streams}{$id} = 1;
3424  
3425 0 return 'ignored';
3426 }
3427  
3428 3 my $handler = $self->{extension_stream_handlers}{$type};
3429  
3430 3 ▶ if (!defined $handler) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $handler) 1 2 3
3431 $stream->consume(length($state->{buffer}))
3432 1 ▶ if length($state->{buffer});
Branch: 1 branch
BranchTrueFalseTotal
if length $state->{"buffer"} 1 0 1
3433  
3434 1 delete $self->{peer_uni_probe}{$id};
3435 1 $self->{ignored_uni_streams}{$id} = 1;
3436  
3437 1 return 'ignored';
3438 }
3439  
3440 my $payload = substr(
3441 $state->{buffer},
3442 2 $type_length,
3443 );
3444  
3445 2 $stream->consume($type_length);
3446  
3447 2 require Unblock::HTTP3::Extension::Stream;
3448  
3449 my $extension = Unblock::HTTP3::Extension::Stream->_new(
3450 connection => $self,
3451 stream => $stream,
3452 type => $type,
3453 header_length => $type_length,
3454 incoming => 1,
3455 initial => $payload,
3456 initial_fin => $state->{fin},
3457 2 );
3458  
3459 2 delete $self->{peer_uni_probe}{$id};
3460 2 $self->{extension_stream_objects}{$id} = $extension;
3461  
3462 2 $handler->($self, $extension);
3463 2 $extension->_drain_receive;
3464  
3465 2 return 'extension';
3466 }
3467  
3468 40 my $chunk = $stream->next_data_chunk;
3469  
3470 40 ▶ if (!defined $chunk) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $chunk) 0 40 40
3471 0 ▶ if ($stream->remote_finished) {
Branch: 1 branch
BranchTrueFalseTotal
if ($stream->remote_finished) 0 0 0
3472 $stream->consume(length($state->{buffer}))
3473 0 ▶ if length($state->{buffer});
Branch: 1 branch
BranchTrueFalseTotal
if length $state->{"buffer"} 0 0 0
3474  
3475 0 delete $self->{peer_uni_probe}{$id};
3476 0 $self->{ignored_uni_streams}{$id} = 1;
3477  
3478 0 return 'ignored';
3479 }
3480  
3481 0 return 'pending';
3482 }
3483  
3484 40 my ($bytes, $fin) = @$chunk;
3485 40 $state->{buffer} .= $bytes;
3486 40 ▶ $state->{fin} ||= $fin ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$fin ? : 0 40 40
Condition33%1/3
$state->{"fin"} ||= $fin ? 1 : 0
l!l&&r!l&&!r
0040
MC/DC0%0/2
$state->{"fin"} ||= $fin ? 1 : 0
$state->{"fin"} $fin ? 1 : 0
Truth table33%1/3
A ||= B
A= $state->{"fin"}B= $fin ? 1 : 0
ABresult
1X1
011
000
3487  
3488 40 ▶ if ($fin && !length($state->{buffer})) {
Branch: 1 branch
BranchTrueFalseTotal
if ($fin and not length $state->{"buffer"}) 0 40 40
Condition33%1/3
$fin and not length $state->{"buffer"}
!ll&&!rl&&r
4000
MC/DC0%0/2
$fin and not length $state->{"buffer"}
$fin not length $state->{"buffer"}
Truth table33%1/3
A and not(B)
A= $finB= not length $state->{"buffer"}
ABresult
0X0
100
111
3489 0 delete $self->{peer_uni_probe}{$id};
3490 0 $self->{ignored_uni_streams}{$id} = 1;
3491 0 return 'ignored';
3492 }
3493 }
3494 }
3495  
3496 4 ▶sub _is_local_critical_stream {
Subroutine _is_local_critical_stream: called CC=7 SCAR=22.1
3497 4 my ($self, $id) = @_;
3498  
3499 return 1
3500 if defined($self->{control_stream_id})
3501 4 ▶ && $id == $self->{control_stream_id};
Branch: 1 branch
BranchTrueFalseTotal
if defined $self->{"control_stream_id"} and $id == $self->{"control_stream_id"} 0 4 4
Condition33%1/3
defined $self->{"control_stream_id"} and $id == $self->{"control_stream_id"}
!ll&&!rl&&r
040
MC/DC0%0/2
defined $self->{"control_stream_id"} and $id == $self->{"control_stream_id"}
defined $self->{"control_stream_id"} $id == $self->{"control_stream_id"}
Truth table33%1/3
A and B
A= defined $self->{"control_stream_id"}B= $id == $self->{"control_stream_id"}
ABresult
0X0
100
111
3502 return 1
3503 if defined($self->{qpack_encoder_stream_id})
3504 4 ▶ && $id == $self->{qpack_encoder_stream_id};
Branch: 1 branch
BranchTrueFalseTotal
if defined $self->{"qpack_encoder_stream_id"} and $id == $self->{"qpack_encoder_stream_id"} 1 3 4
Condition66%2/3
defined $self->{"qpack_encoder_stream_id"} and $id == $self->{"qpack_encoder_stream_id"}
!ll&&!rl&&r
031
MC/DC50%1/2
defined $self->{"qpack_encoder_stream_id"} and $id == $self->{"qpack_encoder_stream_id"}
defined $self->{"qpack_encoder_stream_id"} $id == $self->{"qpack_encoder_stream_id"}
Truth table66%2/3
A and B
A= defined $self->{"qpack_encoder_stream_id"}B= $id == $self->{"qpack_encoder_stream_id"}
ABresult
0X0
100
111
3505 return 1
3506 if defined($self->{qpack_decoder_stream_id})
3507 3 ▶ && $id == $self->{qpack_decoder_stream_id};
Branch: 1 branch
BranchTrueFalseTotal
if defined $self->{"qpack_decoder_stream_id"} and $id == $self->{"qpack_decoder_stream_id"} 0 3 3
Condition33%1/3
defined $self->{"qpack_decoder_stream_id"} and $id == $self->{"qpack_decoder_stream_id"}
!ll&&!rl&&r
030
MC/DC0%0/2
defined $self->{"qpack_decoder_stream_id"} and $id == $self->{"qpack_decoder_stream_id"}
defined $self->{"qpack_decoder_stream_id"} $id == $self->{"qpack_decoder_stream_id"}
Truth table33%1/3
A and B
A= defined $self->{"qpack_decoder_stream_id"}B= $id == $self->{"qpack_decoder_stream_id"}
ABresult
0X0
100
111
3508  
3509 3 return 0;
3510 }
3511  
3512 505 ▶sub _service_stream {
Subroutine _service_stream: called CC=47 SCAR=39.0
3513 505 my ($self, $id) = @_;
3514  
3515 505 my $stream = $self->{streams}{$id};
3516 505 ▶ return unless defined $stream;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $stream 0 505 505
3517  
3518 505 ▶ if (my $extension = $self->{extension_stream_objects}{$id}) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $extension = $self->{"extension_stream_objects"}{$id}) 12 493 505
3519 12 $self->_service_extension_stream(
3520 $id,
3521 $stream,
3522 $extension,
3523 );
3524 12 return;
3525 }
3526  
3527 493 ▶ if ($self->{ignored_uni_streams}{$id}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"ignored_uni_streams"}{$id}) 3 490 493
3528 3 $self->_service_ignored_uni_stream($id, $stream);
3529 3 return;
3530 }
3531  
3532 490 ▶ if (
Branch: 1 branch
BranchTrueFalseTotal
unless ($stream->bidirectional or $stream->local_initiated or $self->{"core_uni_streams"}{$id} or exists $self->{"peer_uni_probe"}{$id}) 40 450 490
Condition88%8/9
$stream->bidirectional or $stream->local_initiated or $self->{"core_uni_streams"}{$id} or exists $self->{"peer_uni_probe"}{$id}
l!l&&r!l&&!r
450040
$stream->bidirectional or $stream->local_initiated or $self->{"core_uni_streams"}{$id}
l!l&&r!l&&!r
3589240
$stream->bidirectional or $stream->local_initiated
l!l&&r!l&&!r
27484132
MC/DC75%3/4
$stream->bidirectional or $stream->local_initiated or $self->{"core_uni_streams"}{$id} or exists $self->{"peer_uni_probe"}{$id}
$stream->bidirectional $stream->local_initiated $self->{"core_uni_streams"}{$id} exists $self->{"peer_uni_probe"}{$id}
Truth table80%4/5
A or B or C or D
A= $stream->bidirectionalB= $stream->local_initiatedC= $self->{"core_uni_streams"}{$id}D= exists $self->{"peer_uni_probe"}{$id}
ABCDresult
1XXX1
01XX1
001X1
00011
00000
3533 !$stream->bidirectional
3534 && !$stream->local_initiated
3535 && !$self->{core_uni_streams}{$id}
3536 && !exists($self->{peer_uni_probe}{$id})
3537 ) {
3538 40 $self->{peer_uni_probe}{$id} = {
3539 buffer => '',
3540 fin => 0,
3541 };
3542 }
3543  
3544 490 ▶ if (exists $self->{peer_uni_probe}{$id}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $self->{"peer_uni_probe"}{$id}) 40 450 490
3545 40 my $kind = $self->_classify_peer_uni_stream(
3546 $id,
3547 $stream,
3548 );
3549  
3550 40 ▶ if ($kind eq 'extension') {
Branch: 1 branch
BranchTrueFalseTotal
if ($kind eq "extension") 2 38 40
3551 2 my $extension = $self->{extension_stream_objects}{$id};
3552 2 ▶ $self->_service_extension_stream(
Branch: 1 branch
BranchTrueFalseTotal
if defined $extension 2 0 2
3553 $id,
3554 $stream,
3555 $extension,
3556 ) if defined $extension;
3557 2 return;
3558 }
3559  
3560 38 ▶ if ($kind eq 'ignored') {
Branch: 1 branch
BranchTrueFalseTotal
if ($kind eq "ignored") 1 37 38
3561 1 $self->_service_ignored_uni_stream($id, $stream);
3562 1 return;
3563 }
3564  
3565 37 ▶ return if $kind ne 'core';
Branch: 1 branch
BranchTrueFalseTotal
if $kind ne "core" 2 35 37
3566 35 ▶ return if $self->{failed};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"failed"} 0 35 35
3567 }
3568  
3569 485 ▶ if ($self->{rejected_streams}{$id}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"rejected_streams"}{$id}) 5 480 485
3570 5 ▶ if ($stream->can_receive) {
Branch: 1 branch
BranchTrueFalseTotal
if ($stream->can_receive) 5 0 5
3571 5 ▶ while (my $chunk = $stream->next_data_chunk) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $chunk = $stream->next_data_chunk) 0 5 5
3572 0 my ($bytes) = @$chunk;
3573 0 ▶ $stream->consume(length($bytes))
Branch: 1 branch
BranchTrueFalseTotal
if length $bytes 0 0 0
3574 if length($bytes);
3575 }
3576 }
3577  
3578 5 ▶ if ($stream->closed) {
Branch: 1 branch
BranchTrueFalseTotal
if ($stream->closed) 2 3 5
3579 2 $self->_release_peer_bidi_stream_credit(
3580 $id,
3581 $stream,
3582 );
3583 2 $self->{native}->discard_body($id);
3584 2 delete $self->{streams}{$id};
3585 2 delete $self->{stream_lifecycle}{$id};
3586 2 delete $self->{rejected_streams}{$id};
3587 }
3588  
3589 5 return;
3590 }
3591  
3592 480 ▶ if ($stream->can_receive) {
Branch: 1 branch
BranchTrueFalseTotal
if ($stream->can_receive) 396 84 480
3593 396 while (1) {
3594 582 my $chunk = $stream->next_data_chunk;
3595 582 ▶ last unless defined $chunk;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $chunk 393 189 582
3596  
3597 189 my ($bytes, $fin) = @$chunk;
3598  
3599 189 $self->_inspect_peer_settings_bytes($id, $bytes);
3600 189 ▶ return if $self->{failed};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"failed"} 0 189 189
3601  
3602 my $result = $self->{native}->read_stream(
3603 189 ▶ $id,
Branch: 1 branch
BranchTrueFalseTotal
$fin ? : 47 142 189
3604 $bytes,
3605 $fin ? 1 : 0,
3606 _now_ns(),
3607 );
3608  
3609 189 ▶ if (@$result > 1) {
Branch: 1 branch
BranchTrueFalseTotal
if (@$result > 1) 2 187 189
3610 2 my ($unused, $lib_error, $app_error, $detail) = @$result;
3611  
3612 2 $self->_fail_connection(
3613 $app_error,
3614 "libnghttp3 read error: $detail ($lib_error)",
3615 );
3616 2 return;
3617 }
3618  
3619 187 my $consumed = $result->[0];
3620 187 ▶ $stream->consume($consumed) if $consumed;
Branch: 1 branch
BranchTrueFalseTotal
if $consumed 133 54 187
3621 187 $self->_drain_events;
3622 187 ▶ return if $self->{failed};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"failed"} 1 186 187
3623 }
3624 }
3625  
3626 477 ▶ if ($stream->can_send) {
Branch: 1 branch
BranchTrueFalseTotal
if ($stream->can_send) 351 126 477
3627 351 my $acked_offset = $stream->acked_offset;
3628  
3629 351 ▶ if (
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->{"control_stream_id"} and $id == $self->{"control_stream_id"}) 12 339 351
Condition100%3/3
defined $self->{"control_stream_id"} and $id == $self->{"control_stream_id"}
!ll&&!rl&&r
333612
MC/DC100%2/2
defined $self->{"control_stream_id"} and $id == $self->{"control_stream_id"}
defined $self->{"control_stream_id"} $id == $self->{"control_stream_id"}
Truth table100%3/3
A and B
A= defined $self->{"control_stream_id"}B= $id == $self->{"control_stream_id"}
ABresult
0X0
100
111
3630 defined($self->{control_stream_id})
3631 && $id == $self->{control_stream_id}
3632 ) {
3633 12 ▶ if (defined $self->{control_settings_pending}) {
Branch: 2 branches
BranchTrueFalseTotal
if (defined $self->{'control_settings_pending'}) { } 0 12 12
elsif ($self->{'control_settings_delta'}) { } 9 3 12
3634 0 $acked_offset = 0;
3635 } elsif ($self->{control_settings_delta}) {
3636 9 my $delta = $self->{control_settings_delta};
3637 9 ▶ $acked_offset = $acked_offset > $delta
Branch: 1 branch
BranchTrueFalseTotal
$acked_offset > $delta ? : 9 0 9
3638 ? $acked_offset - $delta
3639 : 0;
3640 }
3641 }
3642  
3643 $self->{native}->update_ack_offset(
3644 351 $id,
3645 $acked_offset,
3646 );
3647 351 $self->_drain_events;
3648 351 ▶ return if $self->{failed};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"failed"} 0 351 351
3649 351 $self->_drain_body_producers;
3650 }
3651  
3652 477 ▶ my $lifecycle = $self->{stream_lifecycle}{$id} ||= {};
Condition100%2/2
$self->{"stream_lifecycle"}{$id} ||= {}
l!l
355122
MC/DC100%1/1
$self->{"stream_lifecycle"}{$id} ||= {}
$self->{"stream_lifecycle"}{$id}
Truth table100%2/2
A
A= $self->{"stream_lifecycle"}{$id}
Aresult
11
00
3653  
3654 477 my $remote_reset = $stream->remote_reset_code;
3655 477 ▶ if (defined($remote_reset) && !$lifecycle->{remote_reset_seen}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $remote_reset and not $lifecycle->{"remote_reset_seen"}) 4 473 477
Condition100%3/3
defined $remote_reset and not $lifecycle->{"remote_reset_seen"}
!ll&&!rl&&r
47214
MC/DC100%2/2
defined $remote_reset and not $lifecycle->{"remote_reset_seen"}
defined $remote_reset not $lifecycle->{"remote_reset_seen"}
Truth table100%3/3
A and not(B)
A= defined $remote_resetB= not $lifecycle->{"remote_reset_seen"}
ABresult
0X0
100
111
3656 4 $lifecycle->{remote_reset_seen} = 1;
3657 4 $lifecycle->{remote_reset_code} = 0 + $remote_reset;
3658  
3659 4 ▶ if ($self->{core_uni_streams}{$id}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"core_uni_streams"}{$id}) 1 3 4
3660 1 $self->_fail_connection(
3661 $H3_CLOSED_CRITICAL_STREAM,
3662 'peer reset a critical HTTP/3 stream',
3663 );
3664 1 return;
3665 }
3666  
3667 3 $self->{native}->shutdown_stream_read($id);
3668  
3669 3 my $transaction = $self->{transactions}{$id};
3670 3 ▶ if (defined $transaction) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $transaction) 2 1 3
3671 2 $transaction->_mark_remote_reset($remote_reset);
3672 2 ▶ $transaction->_mark_cancelled
Branch: 1 branch
BranchTrueFalseTotal
unless $transaction->is_terminal 1 1 2
3673 unless $transaction->is_terminal;
3674 }
3675 }
3676  
3677 476 my $remote_stop = $stream->remote_stop_sending_code;
3678 476 ▶ if (defined($remote_stop) && !$lifecycle->{remote_stop_seen}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $remote_stop and not $lifecycle->{"remote_stop_seen"}) 4 472 476
Condition100%3/3
defined $remote_stop and not $lifecycle->{"remote_stop_seen"}
!ll&&!rl&&r
46664
MC/DC100%2/2
defined $remote_stop and not $lifecycle->{"remote_stop_seen"}
defined $remote_stop not $lifecycle->{"remote_stop_seen"}
Truth table100%3/3
A and not(B)
A= defined $remote_stopB= not $lifecycle->{"remote_stop_seen"}
ABresult
0X0
100
111
3679 4 $lifecycle->{remote_stop_seen} = 1;
3680 4 $lifecycle->{remote_stop_sending_code} = 0 + $remote_stop;
3681  
3682 4 ▶ if ($self->_is_local_critical_stream($id)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->_is_local_critical_stream($id)) 1 3 4
3683 1 $self->_fail_connection(
3684 $H3_CLOSED_CRITICAL_STREAM,
3685 'peer requested closure of a critical HTTP/3 stream',
3686 );
3687 1 return;
3688 }
3689  
3690 3 $self->{native}->shutdown_stream_write($id);
3691 3 $self->{native}->discard_body($id);
3692  
3693 3 my $transaction = $self->{transactions}{$id};
3694 3 ▶ if (defined $transaction) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $transaction) 2 1 3
3695 2 $transaction->_mark_remote_stop_sending($remote_stop);
3696 2 ▶ $transaction->_mark_cancelled
Branch: 1 branch
BranchTrueFalseTotal
unless $transaction->is_terminal 2 0 2
3697 unless $transaction->is_terminal;
3698 }
3699 }
3700  
3701 475 ▶ if ($stream->closed && !$lifecycle->{closed_seen}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($stream->closed and not $lifecycle->{"closed_seen"}) 46 429 475
Condition66%2/3
$stream->closed and not $lifecycle->{"closed_seen"}
!ll&&!rl&&r
429046
MC/DC50%1/2
$stream->closed and not $lifecycle->{"closed_seen"}
$stream->closed not $lifecycle->{"closed_seen"}
Truth table66%2/3
A and not(B)
A= $stream->closedB= not $lifecycle->{"closed_seen"}
ABresult
0X0
100
111
3702 46 $lifecycle->{closed_seen} = 1;
3703  
3704 46 ▶ if ($self->{core_uni_streams}{$id}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"core_uni_streams"}{$id}) 0 46 46
3705 0 $self->_fail_connection(
3706 $H3_CLOSED_CRITICAL_STREAM,
3707 'peer closed a critical HTTP/3 stream',
3708 );
3709 0 return;
3710 }
3711  
3712 $self->_release_peer_bidi_stream_credit(
3713 46 $id,
3714 $stream,
3715 );
3716  
3717 $self->{native}->close_stream(
3718 46 $id,
3719 $remote_reset,
3720 $stream->local_reset_code,
3721 );
3722  
3723 46 $self->_cleanup_stream_if_done($id);
3724 }
3725  
3726 475 return;
3727 }
3728  
3729 1070 ▶sub _drain_events {
Subroutine _drain_events: called CC=54 SCAR=53.2
3730 1070 my ($self) = @_;
3731  
3732 1070 ▶ while (!$self->{failed} && (my $event = $self->{native}->next_event)) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $self->{"failed"} and my $event = $self->{"native"}->next_event) 217 1070 1287
Condition100%3/3
not $self->{"failed"} and my $event = $self->{"native"}->next_event
!ll&&!rl&&r
11069217
MC/DC100%2/2
not $self->{"failed"} and my $event = $self->{"native"}->next_event
not $self->{"failed"} my $event = $self->{"native"}->next_event
Truth table100%3/3
not(A) and B
A= not $self->{"failed"}B= my $event = $self->{"native"}->next_event
ABresult
0X0
100
111
3733 217 my ($type, $id, @args) = @$event;
3734  
3735 217 ▶ if ($type eq 'settings') {
Branch: 1 branch
BranchTrueFalseTotal
if ($type eq "settings") 12 205 217
3736 12 $self->{peer_max_field_section_size} = "$args[0]";
3737 12 ▶ $self->{peer_enable_connect_protocol} = $args[1] ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$args[1] ? : 5 7 12
3738 12 ▶ $self->{peer_h3_datagram} = $args[2] ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$args[2] ? : 8 4 12
3739 12 $self->_accept_peer_extension_settings;
3740 12 next;
3741 }
3742  
3743 205 ▶ if ($type eq 'origin') {
Branch: 1 branch
BranchTrueFalseTotal
if ($type eq "origin") 2 203 205
3744 2 ▶ push @{ $self->{peer_origin_pending} }, $args[0]
Branch: 1 branch
BranchTrueFalseTotal
if _valid_origin_serialization($args[0]) 2 0 2
3745 if _valid_origin_serialization($args[0]);
3746 2 next;
3747 }
3748  
3749 203 ▶ if ($type eq 'end_origin') {
Branch: 1 branch
BranchTrueFalseTotal
if ($type eq "end_origin") 1 202 203
3750 $self->{peer_origins} = []
3751 1 ▶ unless defined $self->{peer_origins};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->{"peer_origins"} 1 0 1
3752  
3753 1 push @{ $self->{peer_origins} },
3754 1 @{ $self->{peer_origin_pending} };
3755  
3756 1 $self->{peer_origin_pending} = [];
3757 1 next;
3758 }
3759  
3760 202 ▶ if ($self->{rejected_streams}{$id}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"rejected_streams"}{$id}) 0 202 202
3761 0 ▶ if ($type eq 'data') {
Branch: 2 branches
BranchTrueFalseTotal
if ($type eq 'data') { } 0 0 0
elsif ($type eq 'deferred_consume') { } 0 0 0
3762 0 my $stream = $self->{streams}{$id};
3763 0 ▶ $stream->consume(length($args[0]))
Branch: 1 branch
BranchTrueFalseTotal
if defined $stream and length $args[0] 0 0 0
Condition0%0/3
defined $stream and length $args[0]
!ll&&!rl&&r
000
MC/DC0%0/2
defined $stream and length $args[0]
defined $stream length $args[0]
Truth table0%0/3
A and B
A= defined $streamB= length $args[0]
ABresult
0X0
100
111
3764 if defined($stream) && length($args[0]);
3765 } elsif ($type eq 'deferred_consume') {
3766 0 my $stream = $self->{streams}{$id};
3767 0 ▶ $stream->consume($args[0])
Branch: 1 branch
BranchTrueFalseTotal
if defined $stream and $args[0] 0 0 0
Condition0%0/3
defined $stream and $args[0]
!ll&&!rl&&r
000
MC/DC0%0/2
defined $stream and $args[0]
defined $stream $args[0]
Truth table0%0/3
A and B
A= defined $streamB= $args[0]
ABresult
0X0
100
111
3768 if defined($stream) && $args[0];
3769 }
3770 0 next;
3771 }
3772  
3773 202 ▶ if ($type eq 'headers') {
Branch: 1 branch
BranchTrueFalseTotal
if ($type eq "headers") 54 148 202
3774 54 my ($field_section_size, $fin) = @args;
3775  
3776 54 ▶ if (
Branch: 1 branch
BranchTrueFalseTotal
if ($field_section_size > $self->{"max_field_section_size"}) 0 54 54
3777 $field_section_size
3778 > $self->{max_field_section_size}
3779 ) {
3780 0 $self->_fail_connection(
3781 $H3_EXCESSIVE_LOAD,
3782 'HTTP/3 field section exceeds configured limit',
3783 );
3784 0 next;
3785 }
3786  
3787 $self->_finish_headers(
3788 54 ▶ $id,
Branch: 1 branch
BranchTrueFalseTotal
$fin ? : 0 54 54
3789 $fin ? 1 : 0,
3790 );
3791 54 next;
3792 }
3793  
3794 148 ▶ if ($type eq 'data') {
Branch: 1 branch
BranchTrueFalseTotal
if ($type eq "data") 42 106 148
3795 42 my $bytes = $args[0];
3796 42 my $message = $self->{messages}{$id};
3797  
3798 42 ▶ croak "received HTTP/3 DATA before message headers"
Branch: 1 branch
BranchTrueFalseTotal
unless defined $message 0 42 42
3799 unless defined $message;
3800  
3801 42 ▶ my $transaction = $self->{transactions}{$id}
Branch: 1 branch
BranchTrueFalseTotal
my $transaction = $self->{"transactions"}{$id} or croak("received HTTP/3 DATA for unknown Transaction") 42 0 42
3802 or croak "received HTTP/3 DATA for unknown Transaction";
3803 42 ▶ my $kind = $self->{role} eq 'server'
Branch: 1 branch
BranchTrueFalseTotal
$self->{'role'} eq 'server' ? : 16 26 42
3804 ? 'request'
3805 : 'response';
3806 42 my $reader = $transaction->_incoming_body_reader($kind);
3807  
3808 42 ▶ if (defined $reader) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $reader) 25 17 42
3809 25 ▶ if (
Branch: 1 branch
BranchTrueFalseTotal
if ($reader->pending_bytes + length($bytes) > $self->{"max_streaming_body_bytes"}) 0 25 25
3810 $reader->pending_bytes + length($bytes)
3811 > $self->{max_streaming_body_bytes}
3812 ) {
3813 0 $self->_fail_connection(
3814 $H3_EXCESSIVE_LOAD,
3815 'HTTP/3 streaming body queue exceeds configured limit',
3816 );
3817 0 next;
3818 }
3819  
3820 25 $reader->_push_owned($bytes);
3821 25 next;
3822 }
3823  
3824 17 my $current = $transaction->_buffered_body_bytes($kind);
3825  
3826 17 ▶ if (
Branch: 1 branch
BranchTrueFalseTotal
if ($current + length($bytes) > $self->{"max_buffered_body_bytes"}) 1 16 17
3827 $current + length($bytes)
3828 > $self->{max_buffered_body_bytes}
3829 ) {
3830 1 $self->_fail_connection(
3831 $H3_EXCESSIVE_LOAD,
3832 'HTTP/3 buffered body exceeds configured limit',
3833 );
3834 1 next;
3835 }
3836  
3837 16 $transaction->_append_buffered_body($kind, $bytes);
3838  
3839 16 my $stream = $self->{streams}{$id};
3840 16 ▶ $stream->consume(length($bytes))
Branch: 1 branch
BranchTrueFalseTotal
if defined $stream and length $bytes 16 0 16
Condition33%1/3
defined $stream and length $bytes
!ll&&!rl&&r
0016
MC/DC0%0/2
defined $stream and length $bytes
defined $stream length $bytes
Truth table33%1/3
A and B
A= defined $streamB= length $bytes
ABresult
0X0
100
111
3841 if defined($stream) && length($bytes);
3842  
3843 16 next;
3844 }
3845  
3846 106 ▶ if ($type eq 'deferred_consume') {
Branch: 1 branch
BranchTrueFalseTotal
if ($type eq "deferred_consume") 0 106 106
3847 0 my $stream = $self->{streams}{$id};
3848 0 ▶ $stream->consume($args[0])
Branch: 1 branch
BranchTrueFalseTotal
if defined $stream and $args[0] 0 0 0
Condition0%0/3
defined $stream and $args[0]
!ll&&!rl&&r
000
MC/DC0%0/2
defined $stream and $args[0]
defined $stream $args[0]
Truth table0%0/3
A and B
A= defined $streamB= $args[0]
ABresult
0X0
100
111
3849 if defined($stream) && $args[0];
3850 0 next;
3851 }
3852  
3853 106 ▶ if ($type eq 'end_stream') {
Branch: 1 branch
BranchTrueFalseTotal
if ($type eq "end_stream") 46 60 106
3854 46 my $transaction = $self->{transactions}{$id};
3855 46 ▶ if (defined $transaction) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $transaction) 46 0 46
3856 46 ▶ my $kind = $self->{role} eq 'server'
Branch: 1 branch
BranchTrueFalseTotal
$self->{'role'} eq 'server' ? : 24 22 46
3857 ? 'request'
3858 : 'response';
3859 46 my $reader = $transaction->_incoming_body_reader($kind);
3860  
3861 46 ▶ if (defined $reader) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $reader) { } 14 32 46
3862 14 $reader->_mark_end;
3863  
3864 14 my $message = $self->{messages}{$id};
3865 14 ▶ if (defined $message) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $message) 14 0 14
3866 14 $message->freeze_trailers;
3867 14 $message->freeze;
3868 14 $message->mark_complete;
3869 }
3870 } else {
3871 32 $transaction->_finish_received_message($kind);
3872 }
3873 }
3874  
3875 46 $self->_maybe_complete_transaction($id);
3876 46 next;
3877 }
3878  
3879 60 ▶ if ($type eq 'stop_sending') {
Branch: 1 branch
BranchTrueFalseTotal
if ($type eq "stop_sending") 0 60 60
3880 0 my $stream = $self->{streams}{$id};
3881 0 ▶ if (defined($stream) && $stream->can_receive) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $stream and $stream->can_receive) 0 0 0
Condition0%0/3
defined $stream and $stream->can_receive
!ll&&!rl&&r
000
MC/DC0%0/2
defined $stream and $stream->can_receive
defined $stream $stream->can_receive
Truth table0%0/3
A and B
A= defined $streamB= $stream->can_receive
ABresult
0X0
100
111
3882 0 $stream->stop_sending($args[0]);
3883 0 my $transaction = $self->{transactions}{$id};
3884 0 ▶ $transaction->_mark_local_stop_sending($args[0])
Branch: 1 branch
BranchTrueFalseTotal
if defined $transaction 0 0 0
3885 if defined $transaction;
3886 }
3887 0 next;
3888 }
3889  
3890 60 ▶ if ($type eq 'reset_stream') {
Branch: 1 branch
BranchTrueFalseTotal
if ($type eq "reset_stream") 0 60 60
3891 0 my $transaction = $self->{transactions}{$id};
3892 0 ▶ $transaction->_mark_local_reset($args[0])
Branch: 1 branch
BranchTrueFalseTotal
if defined $transaction 0 0 0
3893 if defined $transaction;
3894  
3895 0 my $stream = $self->{streams}{$id};
3896 0 ▶ $stream->reset($args[0])
Branch: 1 branch
BranchTrueFalseTotal
if defined $stream and $stream->can_send 0 0 0
Condition0%0/3
defined $stream and $stream->can_send
!ll&&!rl&&r
000
MC/DC0%0/2
defined $stream and $stream->can_send
defined $stream $stream->can_send
Truth table0%0/3
A and B
A= defined $streamB= $stream->can_send
ABresult
0X0
100
111
3897 if defined($stream) && $stream->can_send;
3898 0 next;
3899 }
3900  
3901 60 ▶ if ($type eq 'begin_trailers') {
Branch: 1 branch
BranchTrueFalseTotal
if ($type eq "begin_trailers") 4 56 60
3902 4 $self->{trailer_field_section_size}{$id} = 0;
3903 4 next;
3904 }
3905  
3906 56 ▶ if ($type eq 'trailer') {
Branch: 1 branch
BranchTrueFalseTotal
if ($type eq "trailer") 6 50 56
3907 6 my $message = $self->{messages}{$id};
3908  
3909 6 ▶ croak "received HTTP/3 trailer before message headers"
Branch: 1 branch
BranchTrueFalseTotal
unless defined $message 0 6 6
3910 unless defined $message;
3911  
3912 $self->{trailer_field_section_size}{$id}
3913 6 ▶ = ($self->{trailer_field_section_size}{$id} // 0)
Condition50%1/2
$self->{"trailer_field_section_size"}{$id} // 0
l!l
60
MC/DC0%0/1
$self->{"trailer_field_section_size"}{$id} // 0
$self->{"trailer_field_section_size"}{$id}
Truth table50%1/2
A
A= $self->{"trailer_field_section_size"}{$id}
Aresult
11
00
3914 + length($args[0]) + length($args[1]) + 32;
3915  
3916 6 ▶ if (
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"trailer_field_section_size"}{$id} > $self->{"max_field_section_size"}) 0 6 6
3917 $self->{trailer_field_section_size}{$id}
3918 > $self->{max_field_section_size}
3919 ) {
3920 0 $self->_fail_connection(
3921 $H3_EXCESSIVE_LOAD,
3922 'HTTP/3 trailer field section exceeds configured limit',
3923 );
3924 0 next;
3925 }
3926  
3927 $message->add_trailer(
3928 6 $args[0],
3929 $args[1],
3930 );
3931 6 next;
3932 }
3933  
3934 50 ▶ if ($type eq 'end_trailers') {
Branch: 1 branch
BranchTrueFalseTotal
if ($type eq "end_trailers") 4 46 50
3935 4 delete $self->{trailer_field_section_size}{$id};
3936 4 my $message = $self->{messages}{$id};
3937  
3938 4 ▶ if (defined $message) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $message) 4 0 4
3939 4 _coalesce_trailer_cookie_fields($message);
3940 4 $message->freeze_trailers;
3941 }
3942  
3943 4 next;
3944 }
3945  
3946 46 ▶ if ($type eq 'shutdown') {
Branch: 1 branch
BranchTrueFalseTotal
if ($type eq "shutdown") 0 46 46
3947 0 $self->{remote_shutdown_id} = 0 + $id;
3948 0 next;
3949 }
3950  
3951 46 ▶ if ($type eq 'stream_close') {
Branch: 1 branch
BranchTrueFalseTotal
if ($type eq "stream_close") 46 0 46
3952 46 next;
3953 }
3954  
3955 0 croak "unknown native HTTP/3 event '$type'";
3956 }
3957  
3958 1070 return;
3959 }
3960  
3961 5 ▶sub _coalesce_trailer_cookie_fields {
Subroutine _coalesce_trailer_cookie_fields: called CC=2 SCAR=6.9
3962 5 my ($message) = @_;
3963  
3964 5 my $values = $message->trailer_values('cookie');
3965 5 ▶ return unless @$values > 1;
Branch: 1 branch
BranchTrueFalseTotal
unless @$values > 1 4 1 5
3966  
3967 1 $message->trailer(
3968 'cookie',
3969 join('; ', @$values),
3970 );
3971  
3972 1 return 1;
3973 }
3974  
3975 54 ▶sub _finish_headers {
Subroutine _finish_headers: called CC=56 SCAR=47.6
3976 54 my ($self, $id, $fin) = @_;
3977  
3978 54 my $message;
3979  
3980 54 ▶ if ($self->{role} eq 'server') {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'role'} eq 'server') { } 28 26 54
3981 28 my $method = $self->{native}->header_pseudo($id, ':method');
3982  
3983 28 ▶ croak 'HTTP/3 request is missing :method'
Branch: 1 branch
BranchTrueFalseTotal
unless defined $method 0 28 28
3984 unless defined $method;
3985  
3986 28 my $scheme = $self->{native}->header_pseudo($id, ':scheme');
3987 28 my $authority = $self->{native}->header_pseudo($id, ':authority');
3988 28 my $path = $self->{native}->header_pseudo($id, ':path');
3989 28 my $protocol = $self->{native}->header_pseudo($id, ':protocol');
3990 28 ▶ my $is_connect = $method eq 'CONNECT' ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$method eq 'CONNECT' ? : 8 20 28
3991 28 ▶ my $is_extended_connect =
Branch: 1 branch
BranchTrueFalseTotal
$is_connect && defined $protocol ? : 6 22 28
Condition100%3/3
$is_connect and defined $protocol
!ll&&!rl&&r
2026
MC/DC100%2/2
$is_connect and defined $protocol
$is_connect defined $protocol
Truth table100%3/3
A and B
A= $is_connectB= defined $protocol
ABresult
0X0
100
111
3992 $is_connect && defined($protocol) ? 1 : 0;
3993 28 my $target;
3994 28 my $host_values = $self->{native}->header_values($id, 'host');
3995  
3996 28 ▶ if ($is_connect && !$is_extended_connect) {
Branch: 1 branch
BranchTrueFalseTotal
if ($is_connect and not $is_extended_connect) { } 2 26 28
Condition100%3/3
$is_connect and not $is_extended_connect
!ll&&!rl&&r
2062
MC/DC100%2/2
$is_connect and not $is_extended_connect
$is_connect not $is_extended_connect
Truth table100%3/3
A and not(B)
A= $is_connectB= not $is_extended_connect
ABresult
0X0
100
111
3997 2 ▶ croak 'HTTP/3 CONNECT request is missing :authority'
Branch: 1 branch
BranchTrueFalseTotal
unless defined $authority 0 2 2
3998 unless defined $authority;
3999 2 ▶ croak 'HTTP/3 CONNECT request must not contain :scheme'
Branch: 1 branch
BranchTrueFalseTotal
if defined $scheme 0 2 2
4000 if defined $scheme;
4001 2 ▶ croak 'HTTP/3 CONNECT request must not contain :path'
Branch: 1 branch
BranchTrueFalseTotal
if defined $path 0 2 2
4002 if defined $path;
4003  
4004 2 $target = $authority;
4005  
4006 2 my $semantic_error = _request_semantic_error(
4007 method => 'CONNECT',
4008 scheme => undef,
4009 authority => $authority,
4010 target => $target,
4011 protocol => undef,
4012 host_values => $host_values,
4013 );
4014  
4015 2 ▶ if (defined $semantic_error) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $semantic_error) 0 2 2
4016 0 $self->_reject_message_stream($id, $semantic_error);
4017 0 return;
4018 }
4019 } else {
4020 26 ▶ if ($is_extended_connect && !$self->{enable_extended_connect}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($is_extended_connect and not $self->{"enable_extended_connect"}) 0 26 26
Condition66%2/3
$is_extended_connect and not $self->{"enable_extended_connect"}
!ll&&!rl&&r
2060
MC/DC0%0/2
$is_extended_connect and not $self->{"enable_extended_connect"}
$is_extended_connect not $self->{"enable_extended_connect"}
Truth table66%2/3
A and not(B)
A= $is_extended_connectB= not $self->{"enable_extended_connect"}
ABresult
0X0
100
111
4021 0 $self->_reject_message_stream(
4022 $id,
4023 'Extended CONNECT was not enabled by this server',
4024 );
4025 0 return;
4026 }
4027  
4028 26 ▶ if ($is_extended_connect && !defined $path) {
Branch: 1 branch
BranchTrueFalseTotal
if ($is_extended_connect and not defined $path) 0 26 26
Condition66%2/3
$is_extended_connect and not defined $path
!ll&&!rl&&r
2060
MC/DC0%0/2
$is_extended_connect and not defined $path
$is_extended_connect not defined $path
Truth table66%2/3
A and not(B)
A= $is_extended_connectB= not defined $path
ABresult
0X0
100
111
4029 0 $self->_reject_message_stream(
4030 $id,
4031 'Extended CONNECT requires :path',
4032 );
4033 0 return;
4034 }
4035  
4036 26 ▶ croak 'HTTP/3 request is missing :path'
Branch: 1 branch
BranchTrueFalseTotal
unless defined $path 0 26 26
4037 unless defined $path;
4038  
4039 26 $target = $path;
4040  
4041 26 my $semantic_error = _request_semantic_error(
4042 method => $method,
4043 scheme => $scheme,
4044 authority => $authority,
4045 target => $target,
4046 protocol => $protocol,
4047 host_values => $host_values,
4048 );
4049  
4050 26 ▶ if (defined $semantic_error) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $semantic_error) 1 25 26
4051 1 $self->_reject_message_stream($id, $semantic_error);
4052 1 return;
4053 }
4054  
4055 25 ▶ if (!defined($authority) && @$host_values == 1) {
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $authority and @$host_values == 1) 0 25 25
Condition33%1/3
not defined $authority and @$host_values == 1
!ll&&!rl&&r
2500
MC/DC0%0/2
not defined $authority and @$host_values == 1
not defined $authority @$host_values == 1
Truth table33%1/3
not(A) and B
A= not defined $authorityB= @$host_values == 1
ABresult
0X0
100
111
4056 0 $authority = $host_values->[0];
4057 }
4058 }
4059  
4060 $message = $self->{native}->receive_uniform_request(
4061 27 $id,
4062 $method,
4063 $target,
4064 $scheme,
4065 $authority,
4066 $protocol,
4067 $fin,
4068 );
4069  
4070 27 my $response = Uniform::HTTP::Response->new(
4071 status => 200,
4072 version => '3',
4073 );
4074  
4075 27 my $stream = $self->{streams}{$id};
4076 27 ▶ my $stream_is_early = defined($stream) && $stream->early_data ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
defined $stream && $stream->early_data ? : 1 26 27
Condition66%2/3
defined $stream and $stream->early_data
!ll&&!rl&&r
0261
MC/DC50%1/2
defined $stream and $stream->early_data
defined $stream $stream->early_data
Truth table66%2/3
A and B
A= defined $streamB= $stream->early_data
ABresult
0X0
100
111
4077  
4078 27 ▶ if ($stream_is_early && !defined($self->{remembered_local_settings})) {
Branch: 1 branch
BranchTrueFalseTotal
if ($stream_is_early and not defined $self->{"remembered_local_settings"}) 0 27 27
Condition66%2/3
$stream_is_early and not defined $self->{"remembered_local_settings"}
!ll&&!rl&&r
2610
MC/DC0%0/2
$stream_is_early and not defined $self->{"remembered_local_settings"}
$stream_is_early not defined $self->{"remembered_local_settings"}
Truth table66%2/3
A and not(B)
A= $stream_is_earlyB= not defined $self->{"remembered_local_settings"}
ABresult
0X0
100
111
4079 0 $self->_fail_connection(
4080 $H3_SETTINGS_ERROR,
4081 'received HTTP/3 0-RTT request without remembered_local_settings',
4082 );
4083 0 return;
4084 }
4085  
4086 my $transaction = Unblock::HTTP3::Transaction->_new(
4087 connection => $self,
4088 stream_id => $id,
4089 request => $message,
4090 response => $response,
4091 early_data => $stream_is_early,
4092 callbacks => $self->{callbacks},
4093 27 );
4094  
4095 my $request_receive_mode = $is_connect
4096 || defined($self->{callbacks}{on_body})
4097 ? 'stream'
4098 27 ▶ : $self->{receive_body_mode};
Branch: 1 branch
BranchTrueFalseTotal
$is_connect || defined $self->{'callbacks'}{'on_body'} ? : 8 19 27
Condition66%2/3
$is_connect or defined $self->{"callbacks"}{"on_body"}
l!l&&r!l&&!r
8019
MC/DC50%1/2
$is_connect or defined $self->{"callbacks"}{"on_body"}
$is_connect defined $self->{"callbacks"}{"on_body"}
Truth table66%2/3
A or B
A= $is_connectB= defined $self->{"callbacks"}{"on_body"}
ABresult
1X1
011
000
4099  
4100 27 my %request_receive_options;
4101 27 ▶ if (defined $self->{callbacks}{on_body}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->{"callbacks"}{"on_body"}) 0 27 27
4102 0 ▶ $request_receive_options{on_data} = sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
4103 0 my ($reader, $bytes) = @_;
4104 0 my $result = $transaction->_invoke(
4105 'on_body',
4106 $transaction->request,
4107 $bytes,
4108 );
4109 0 ▶ die $result unless $result eq '1';
Branch: 1 branch
BranchTrueFalseTotal
unless $result eq 1 0 0 0
4110 0 };
4111 }
4112 $transaction->_configure_receive_body(
4113 27 'request',
4114 $request_receive_mode,
4115 \%request_receive_options,
4116 );
4117 27 ▶ $transaction->_ensure_receive_reader('request')
Branch: 1 branch
BranchTrueFalseTotal
if $request_receive_mode eq "stream" 9 18 27
4118 if $request_receive_mode eq 'stream';
4119  
4120 27 $self->{transactions}{$id} = $transaction;
4121  
4122 27 ▶ if (
Branch: 1 branch
BranchTrueFalseTotal
if ($stream_is_early and not $self->{'quic'}->ready) { } 1 26 27
Condition66%2/3
$stream_is_early and not $self->{"quic"}->ready
!ll&&!rl&&r
2601
MC/DC50%1/2
$stream_is_early and not $self->{"quic"}->ready
$stream_is_early not $self->{"quic"}->ready
Truth table66%2/3
A and not(B)
A= $stream_is_earlyB= not $self->{"quic"}->ready
ABresult
0X0
100
111
4123 $stream_is_early
4124 && !$self->{quic}->ready
4125 ) {
4126 1 push @{ $self->{pending_early_transactions} }, $transaction;
4127 } else {
4128 26 my $datagrams = 0;
4129 26 ▶ if (defined $self->{datagram_request}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->{"datagram_request"}) 3 23 26
4130 $datagrams =
4131 3 ▶ $self->{datagram_request}->($self, $message) ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$self->{'datagram_request'}->($self, $message) ? : 1 2 3
4132 }
4133  
4134 26 ▶ $transaction->_enable_datagrams if $datagrams;
Branch: 1 branch
BranchTrueFalseTotal
if $datagrams 1 25 26
4135 26 push @{ $self->{ready_transactions} }, $transaction;
4136  
4137 26 ▶ if (defined $self->{callbacks}{on_request}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->{"callbacks"}{"on_request"}) 23 3 26
4138 23 my $result = $transaction->_invoke(
4139 'on_request',
4140 $transaction->request,
4141 );
4142 23 ▶ die $result unless $result eq '1';
Branch: 1 branch
BranchTrueFalseTotal
unless $result eq 1 0 23 23
4143 }
4144 }
4145 } else {
4146 26 my $status = $self->{native}->header_pseudo($id, ':status');
4147  
4148 26 ▶ croak 'HTTP/3 response is missing :status'
Branch: 1 branch
BranchTrueFalseTotal
unless defined $status 0 26 26
4149 unless defined $status;
4150  
4151 26 ▶ if (
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"native"}->has_header($id, "capsule-protocol") and not 0 + $status >= 200 && 0 + $status < 300) 0 26 26
Condition50%3/6
$self->{"native"}->has_header($id, "capsule-protocol") and not 0 + $status >= 200 && 0 + $status < 300
!ll&&!rl&&r
2420
0 + $status >= 200 && 0 + $status < 300
!ll&&!rl&&r
002
MC/DC0%0/3
$self->{"native"}->has_header($id, "capsule-protocol") and not 0 + $status >= 200 && 0 + $status < 300
$self->{"native"}->has_header($id, "capsule-protocol") 0 + $status >= 200 0 + $status < 300
Truth table50%2/4
A and not(B && C)
A= $self->{"native"}->has_header($id, "capsule-protocol")B= 0 + $status >= 200C= 0 + $status < 300
ABCresult
0XX0
1110
10X1
1101
4152 $self->{native}->has_header($id, 'capsule-protocol')
4153 && !(0 + $status >= 200 && 0 + $status < 300)
4154 ) {
4155 0 $self->_reject_message_stream(
4156 $id,
4157 'Capsule-Protocol is only valid on a successful HTTP/3 response',
4158 );
4159 0 return;
4160 }
4161  
4162 $message = $self->{native}->receive_uniform_response(
4163 26 $id,
4164 0 + $status,
4165 $fin,
4166 );
4167  
4168 26 ▶ my $transaction = $self->{transactions}{$id}
Branch: 1 branch
BranchTrueFalseTotal
my $transaction = $self->{"transactions"}{$id} or croak("received HTTP/3 response for unknown Transaction") 26 0 26
4169 or croak "received HTTP/3 response for unknown Transaction";
4170  
4171 26 ▶ if ($message->status < 200) {
Branch: 1 branch
BranchTrueFalseTotal
if ($message->status < 200) 2 24 26
4172 2 $message->mark_complete;
4173 2 $message->freeze;
4174  
4175 2 ▶ croak 'HTTP/3 does not use 101 Switching Protocols'
Branch: 1 branch
BranchTrueFalseTotal
if $message->status == 101 0 2 2
4176 if $message->status == 101;
4177 2 ▶ croak 'informational HTTP/3 response cannot end the stream'
Branch: 1 branch
BranchTrueFalseTotal
if $fin 0 2 2
4178 if $fin;
4179  
4180 2 $transaction->_push_informational($message);
4181 2 push @{ $self->{ready_informational} }, $transaction;
4182 2 my $result = $transaction->_invoke(
4183 'on_informational',
4184 $message,
4185 );
4186 2 ▶ die $result unless $result eq '1';
Branch: 1 branch
BranchTrueFalseTotal
unless $result eq 1 0 2 2
4187 2 return;
4188 }
4189  
4190 24 $transaction->_set_response($message);
4191 24 my $response_result = $transaction->_invoke(
4192 'on_response',
4193 $message,
4194 );
4195 24 ▶ die $response_result unless $response_result eq '1';
Branch: 1 branch
BranchTrueFalseTotal
unless $response_result eq 1 0 24 24
4196  
4197 24 $transaction->_ensure_receive_reader('response');
4198  
4199 24 ▶ if (
Branch: 1 branch
BranchTrueFalseTotal
if ($transaction->request->method eq "CONNECT" and $message->status < 200 || $message->status >= 300) 2 22 24
Condition83%5/6
$transaction->request->method eq "CONNECT" and $message->status < 200 || $message->status >= 300
!ll&&!rl&&r
1842
$message->status < 200 or $message->status >= 300
l!l&&r!l&&!r
024
MC/DC66%2/3
$transaction->request->method eq "CONNECT" and $message->status < 200 || $message->status >= 300
$transaction->request->method eq "CONNECT" $message->status < 200 $message->status >= 300
Truth table75%3/4
A and B or C
A= $transaction->request->method eq "CONNECT"B= $message->status < 200C= $message->status >= 300
ABCresult
0XX0
1000
11X1
1011
4200 $transaction->request->method eq 'CONNECT'
4201 && ($message->status < 200 || $message->status >= 300)
4202 ) {
4203 2 my $writer = $transaction->_request_body_object;
4204 2 ▶ $writer->complete
Branch: 1 branch
BranchTrueFalseTotal
if defined $writer and not $writer->is_complete 2 0 2
Condition33%1/3
defined $writer and not $writer->is_complete
!ll&&!rl&&r
002
MC/DC0%0/2
defined $writer and not $writer->is_complete
defined $writer not $writer->is_complete
Truth table33%1/3
A and not(B)
A= defined $writerB= not $writer->is_complete
ABresult
0X0
100
111
4205 if defined($writer) && !$writer->is_complete;
4206 }
4207  
4208 24 push @{ $self->{ready_transactions} }, $transaction;
4209 }
4210  
4211 51 my $lifecycle = $self->{stream_lifecycle}{$id};
4212  
4213 51 my $transaction = $self->{transactions}{$id};
4214  
4215 51 ▶ if (defined($lifecycle) && defined($transaction)) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $lifecycle and defined $transaction) 24 27 51
Condition66%2/3
defined $lifecycle and defined $transaction
!ll&&!rl&&r
27024
MC/DC50%1/2
defined $lifecycle and defined $transaction
defined $lifecycle defined $transaction
Truth table66%2/3
A and B
A= defined $lifecycleB= defined $transaction
ABresult
0X0
100
111
4216 24 ▶ if (defined $lifecycle->{remote_reset_code}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $lifecycle->{"remote_reset_code"}) 0 24 24
4217 $transaction->_mark_remote_reset(
4218 $lifecycle->{remote_reset_code},
4219 0 );
4220 0 ▶ $transaction->_mark_cancelled
Branch: 1 branch
BranchTrueFalseTotal
unless $transaction->is_terminal 0 0 0
4221 unless $transaction->is_terminal;
4222 }
4223  
4224 24 ▶ if (defined $lifecycle->{remote_stop_sending_code}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $lifecycle->{"remote_stop_sending_code"}) 0 24 24
4225 $transaction->_mark_remote_stop_sending(
4226 $lifecycle->{remote_stop_sending_code},
4227 0 );
4228 0 ▶ $transaction->_mark_cancelled
Branch: 1 branch
BranchTrueFalseTotal
unless $transaction->is_terminal 0 0 0
4229 unless $transaction->is_terminal;
4230 }
4231 }
4232  
4233 51 $self->{messages}{$id} = $message;
4234 51 return;
4235 }
4236  
4237 13 ▶sub _validate_wire_field {
Subroutine _validate_wire_field: called CC=5 SCAR=16.1
4238 13 my ($context, $name, $value) = @_;
4239  
4240 croak "HTTP/3 does not allow connection-specific field '$name'"
4241 13 ▶ if $CONNECTION_SPECIFIC_FIELD{$name};
Branch: 1 branch
BranchTrueFalseTotal
if $CONNECTION_SPECIFIC_FIELD{$name} 5 8 13
4242  
4243 8 ▶ if ($name eq 'te') {
Branch: 1 branch
BranchTrueFalseTotal
if ($name eq "te") 4 4 8
4244 4 ▶ croak "HTTP/3 TE is only allowed in request headers"
Branch: 1 branch
BranchTrueFalseTotal
unless $context eq "request" 2 2 4
4245 unless $context eq 'request';
4246  
4247 2 my $normalized = $value;
4248 2 $normalized =~ s/\A[ \t]+//;
4249 2 $normalized =~ s/[ \t]+\z//;
4250  
4251 2 ▶ croak "HTTP/3 TE field may contain only 'trailers'"
Branch: 1 branch
BranchTrueFalseTotal
unless lc $normalized eq "trailers" 1 1 2
4252 unless lc($normalized) eq 'trailers';
4253 }
4254  
4255 5 return;
4256 }
4257  
4258 92 ▶sub _decimal_less_than {
Subroutine _decimal_less_than: called CC=6 SCAR=17.9
4259 92 my ($left, $right) = @_;
4260  
4261 92 $left = "$left";
4262 92 $right = "$right";
4263  
4264 92 $left =~ s/\A0+//;
4265 92 $right =~ s/\A0+//;
4266 92 ▶ $left = '0' if $left eq '';
Branch: 1 branch
BranchTrueFalseTotal
if $left eq "" 1 91 92
4267 92 ▶ $right = '0' if $right eq '';
Branch: 1 branch
BranchTrueFalseTotal
if $right eq "" 7 85 92
4268  
4269 92 ▶ return 1 if length($left) < length($right);
Branch: 1 branch
BranchTrueFalseTotal
if length $left < length $right 0 92 92
4270 92 ▶ return 0 if length($left) > length($right);
Branch: 1 branch
BranchTrueFalseTotal
if length $left > length $right 67 25 92
4271  
4272 25 ▶ return $left lt $right ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$left lt $right ? : 3 22 25
4273 }
4274  
4275 0 ▶sub _field_section_size {
Subroutine _field_section_size: not called CC=2 SCAR=17.9
4276 0 my ($fields) = @_;
4277  
4278 0 my $size = 0;
4279  
4280 0 for my $field (@$fields) {
4281 0 $size += length($field->[0]) + length($field->[1]) + 32;
4282 }
4283  
4284 0 return $size;
4285 }
4286  
4287 59 ▶sub _assert_peer_field_section_size_value {
Subroutine _assert_peer_field_section_size_value: called CC=2 SCAR=6.9
4288 59 my ($self, $size, $operation) = @_;
4289  
4290 59 my $limit = $self->{peer_max_field_section_size};
4291  
4292 59 ▶ croak "$operation: field section size $size exceeds peer "
Branch: 1 branch
BranchTrueFalseTotal
if _decimal_less_than($limit, $size) 1 58 59
4293 . "SETTINGS_MAX_FIELD_SECTION_SIZE $limit"
4294 if _decimal_less_than($limit, $size);
4295  
4296 58 return $size;
4297 }
4298  
4299 0 ▶sub _assert_peer_field_section_size {
Subroutine _assert_peer_field_section_size: not called CC=1 SCAR=6.9
4300 0 my ($self, $fields, $operation) = @_;
4301  
4302 0 return _assert_peer_field_section_size_value(
4303 $self,
4304 _field_section_size($fields),
4305 $operation,
4306 );
4307 }
4308  
4309 9 ▶sub _wire_headers {
Subroutine _wire_headers: called CC=4 SCAR=14.0
4310 9 my ($source, $context) = @_;
4311  
4312 9 ▶ croak 'internal HTTP/3 header context must be request or response'
Branch: 1 branch
BranchTrueFalseTotal
if $context ne "request" and $context ne "response" 0 9 9
Condition66%2/3
$context ne "request" and $context ne "response"
!ll&&!rl&&r
720
MC/DC0%0/2
$context ne "request" and $context ne "response"
$context ne "request" $context ne "response"
Truth table66%2/3
A and B
A= $context ne "request"B= $context ne "response"
ABresult
0X0
100
111
4313 if $context ne 'request' && $context ne 'response';
4314  
4315 9 my @headers;
4316  
4317 9 for my $field (@$source) {
4318 10 my $name = $field->[0];
4319 10 my $value = $field->[1];
4320  
4321 10 $name =~ tr/A-Z/a-z/;
4322  
4323 10 _validate_wire_field($context, $name, $value);
4324 3 push @headers, [ $name, $value ];
4325 }
4326  
4327 2 return \@headers;
4328 }
4329  
4330 3 ▶sub _wire_trailers {
Subroutine _wire_trailers: called CC=5 SCAR=16.6
4331 3 my ($source) = @_;
4332  
4333 3 my @trailers;
4334  
4335 3 for my $field (@$source) {
4336 3 my $name = $field->[0];
4337 3 my $value = $field->[1];
4338  
4339 3 $name =~ tr/A-Z/a-z/;
4340  
4341 3 _validate_wire_field('trailer', $name, $value);
4342  
4343 2 ▶ croak "HTTP/3 TE is not allowed in trailers"
Branch: 1 branch
BranchTrueFalseTotal
if $name eq "te" 0 2 2
4344 if $name eq 'te';
4345 2 ▶ croak "HTTP/3 Content-Length is not allowed in trailers"
Branch: 1 branch
BranchTrueFalseTotal
if $name eq "content-length" 1 1 2
4346 if $name eq 'content-length';
4347 1 ▶ croak "HTTP/3 Host is not allowed in trailers"
Branch: 1 branch
BranchTrueFalseTotal
if $name eq "host" 1 0 1
4348 if $name eq 'host';
4349  
4350 0 push @trailers, [ $name, $value ];
4351 }
4352  
4353 0 return \@trailers;
4354 }
4355  
4356 29 ▶sub _submit_request {
Subroutine _submit_request: called CC=15 SCAR=33.7
4357 29 my ($self, $request, $streaming) = @_;
4358  
4359 croak 'request submission requires a client HTTP/3 connection'
4360 29 ▶ unless $self->{role} eq 'client';
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"role"} eq "client" 0 29 29
4361 croak 'HTTP/3 connection has not been started'
4362 29 ▶ unless $self->{started};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"started"} 0 29 29
4363 29 ▶ croak 'request must implement the Uniform HTTP request contract'
Branch: 1 branch
BranchTrueFalseTotal
unless _request_contract($request) 0 29 29
4364 unless _request_contract($request);
4365 croak 'HTTP/3 peer has begun graceful shutdown'
4366 29 ▶ if defined $self->{remote_shutdown_id};
Branch: 1 branch
BranchTrueFalseTotal
if defined $self->{"remote_shutdown_id"} 0 29 29
4367 croak 'HTTP/3 connection is shutting down'
4368 29 ▶ if $self->{shutdown_notice_sent} || $self->{shutdown_started};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"shutdown_notice_sent"} or $self->{"shutdown_started"} 0 29 29
Condition33%1/3
$self->{"shutdown_notice_sent"} or $self->{"shutdown_started"}
l!l&&r!l&&!r
0029
MC/DC0%0/2
$self->{"shutdown_notice_sent"} or $self->{"shutdown_started"}
$self->{"shutdown_notice_sent"} $self->{"shutdown_started"}
Truth table33%1/3
A or B
A= $self->{"shutdown_notice_sent"}B= $self->{"shutdown_started"}
ABresult
1X1
011
000
4369  
4370 29 my ($portable_fields, $portable_trailers);
4371  
4372 29 ▶ if (ref($request) eq 'Uniform::HTTP::Request') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $request eq 'Uniform::HTTP::Request') { } 29 0 29
4373 $self->_assert_peer_field_section_size_value(
4374 29 $self->{native}->uniform_request_field_section_size($request),
4375 'request()',
4376 );
4377  
4378 my $trailer_size =
4379 28 $self->{native}->uniform_trailer_field_section_size($request);
4380  
4381 28 ▶ $self->_assert_peer_field_section_size_value(
Branch: 1 branch
BranchTrueFalseTotal
if $trailer_size 2 26 28
4382 $trailer_size,
4383 'request trailers',
4384 ) if $trailer_size;
4385 } else {
4386 0 $portable_fields = _portable_request_fields($request);
4387 0 $portable_trailers = _portable_trailers($request);
4388  
4389 0 $self->_assert_peer_field_section_size_value(
4390 _field_section_size($portable_fields),
4391 'request()',
4392 );
4393 0 ▶ $self->_assert_peer_field_section_size_value(
Branch: 1 branch
BranchTrueFalseTotal
if @$portable_trailers 0 0 0
4394 _field_section_size($portable_trailers),
4395 'request trailers',
4396 ) if @$portable_trailers;
4397 }
4398  
4399 28 my $stream = $self->{quic}->open_bidi_stream;
4400 28 ▶ return unless defined $stream;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $stream 0 28 28
4401  
4402 28 my $id = $stream->id;
4403 28 $self->{streams}{$id} = $stream;
4404  
4405 28 ▶ $streaming = $streaming ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$streaming ? : 13 15 28
4406  
4407 28 ▶ if (ref($request) eq 'Uniform::HTTP::Request') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $request eq 'Uniform::HTTP::Request') { } 28 0 28
4408 $self->{native}->submit_uniform_request(
4409 28 $id,
4410 $request,
4411 $streaming,
4412 );
4413 28 $request->freeze;
4414 } else {
4415 0 ▶ my $body = $request->has_buffered_body
Branch: 1 branch
BranchTrueFalseTotal
$request->has_buffered_body ? : 0 0 0
4416 ? $request->body
4417 : undef;
4418  
4419 $self->{native}->submit_request(
4420 0 $id,
4421 $portable_fields,
4422 $body,
4423 $streaming,
4424 );
4425  
4426 $self->{native}->submit_trailers(
4427 0 ▶ $id,
Branch: 1 branch
BranchTrueFalseTotal
if @$portable_trailers 0 0 0
4428 $portable_trailers,
4429 ) if @$portable_trailers;
4430 }
4431 28 $self->{outgoing}{$id} = $request;
4432  
4433 28 $self->_drain_output;
4434  
4435 28 return $id;
4436 }
4437  
4438 24 ▶sub _submit_response {
Subroutine _submit_response: called CC=13 SCAR=32.0
4439 24 my ($self, $stream_id, $response) = @_;
4440  
4441 croak 'response submission requires a server HTTP/3 connection'
4442 24 ▶ unless $self->{role} eq 'server';
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"role"} eq "server" 0 24 24
4443 croak 'HTTP/3 connection has not been started'
4444 24 ▶ unless $self->{started};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"started"} 0 24 24
4445 24 ▶ croak 'response must implement the Uniform HTTP response contract'
Branch: 1 branch
BranchTrueFalseTotal
unless _response_contract($response) 0 24 24
4446 unless _response_contract($response);
4447 croak 'unknown HTTP/3 request stream'
4448 24 ▶ unless defined $self->{streams}{$stream_id};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->{"streams"}{$stream_id} 0 24 24
4449  
4450 24 my ($portable_fields, $portable_trailers);
4451  
4452 24 ▶ if (ref($response) eq 'Uniform::HTTP::Response') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $response eq 'Uniform::HTTP::Response') { } 24 0 24
4453 $self->_assert_peer_field_section_size_value(
4454 24 $self->{native}->uniform_response_field_section_size($response),
4455 'respond()',
4456 );
4457  
4458 my $trailer_size =
4459 24 $self->{native}->uniform_trailer_field_section_size($response);
4460  
4461 24 ▶ $self->_assert_peer_field_section_size_value(
Branch: 1 branch
BranchTrueFalseTotal
if $trailer_size 2 22 24
4462 $trailer_size,
4463 'response trailers',
4464 ) if $trailer_size;
4465 } else {
4466 0 $portable_fields = _portable_response_fields($response);
4467 0 $portable_trailers = _portable_trailers($response);
4468  
4469 0 $self->_assert_peer_field_section_size_value(
4470 _field_section_size($portable_fields),
4471 'respond()',
4472 );
4473 0 ▶ $self->_assert_peer_field_section_size_value(
Branch: 1 branch
BranchTrueFalseTotal
if @$portable_trailers 0 0 0
4474 _field_section_size($portable_trailers),
4475 'response trailers',
4476 ) if @$portable_trailers;
4477 }
4478  
4479 24 my $transaction = $self->{transactions}{$stream_id};
4480 24 ▶ my $streaming = defined($transaction)
Branch: 1 branch
BranchTrueFalseTotal
defined $transaction && $transaction->_response_is_streaming ? : 8 16 24
Condition66%2/3
defined $transaction and $transaction->_response_is_streaming
!ll&&!rl&&r
0168
MC/DC50%1/2
defined $transaction and $transaction->_response_is_streaming
defined $transaction $transaction->_response_is_streaming
Truth table66%2/3
A and B
A= defined $transactionB= $transaction->_response_is_streaming
ABresult
0X0
100
111
4481 && $transaction->_response_is_streaming
4482 ? 1
4483 : 0;
4484  
4485 24 ▶ if (ref($response) eq 'Uniform::HTTP::Response') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $response eq 'Uniform::HTTP::Response') { } 24 0 24
4486 $self->{native}->submit_uniform_response(
4487 24 $stream_id,
4488 $response,
4489 $streaming,
4490 );
4491 24 $response->freeze;
4492 } else {
4493 0 ▶ my $body = $response->has_buffered_body
Branch: 1 branch
BranchTrueFalseTotal
$response->has_buffered_body ? : 0 0 0
4494 ? $response->body
4495 : undef;
4496  
4497 $self->{native}->submit_response(
4498 0 $stream_id,
4499 $portable_fields,
4500 $body,
4501 $streaming,
4502 );
4503  
4504 $self->{native}->submit_trailers(
4505 0 ▶ $stream_id,
Branch: 1 branch
BranchTrueFalseTotal
if @$portable_trailers 0 0 0
4506 $portable_trailers,
4507 ) if @$portable_trailers;
4508 }
4509  
4510 24 $self->_drain_output;
4511 24 return $response;
4512 }
4513  
4514 568 ▶sub _drain_output {
Subroutine _drain_output: called CC=20 SCAR=30.3
4515 568 my ($self) = @_;
4516  
4517 568 while (1) {
4518 778 ▶ if (my $pending = $self->{control_settings_pending}) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $pending = $self->{"control_settings_pending"}) 9 769 778
4519 9 my $id = $pending->{id};
4520 9 ▶ my $stream = $self->{streams}{$id}
Branch: 1 branch
BranchTrueFalseTotal
my $stream = $self->{"streams"}{$id} or croak("missing HTTP/3 control stream $id") 9 0 9
4521 or croak "missing HTTP/3 control stream $id";
4522  
4523 my $remaining = substr(
4524 $pending->{bytes},
4525 $pending->{offset},
4526 9 );
4527 9 my $length = length($remaining);
4528 9 ▶ my $accepted = $length
Branch: 1 branch
BranchTrueFalseTotal
$length ? : 9 0 9
4529 ? $stream->send_some($remaining)
4530 : 0;
4531  
4532 9 $pending->{offset} += $accepted;
4533  
4534 9 ▶ last if $pending->{offset} < length($pending->{bytes});
Branch: 1 branch
BranchTrueFalseTotal
if $pending->{"offset"} < length $pending->{"bytes"} 0 9 9
4535  
4536 $self->{native}->add_write_offset(
4537 $id,
4538 $pending->{native_length},
4539 9 );
4540  
4541 9 $self->{control_settings_delta} = $pending->{delta};
4542 9 delete $self->{control_settings_pending};
4543 9 next;
4544 }
4545  
4546 769 my $out = $self->{native}->next_write;
4547 769 ▶ last unless defined $out;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $out 558 211 769
4548  
4549 211 my ($id, $bytes, $fin) = @$out;
4550 211 ▶ my $stream = $self->{streams}{$id}
Branch: 1 branch
BranchTrueFalseTotal
my $stream = $self->{"streams"}{$id} or croak("libnghttp3 selected unknown QUIC stream $id") 211 0 211
4551 or croak "libnghttp3 selected unknown QUIC stream $id";
4552  
4553 211 ▶ if (
Branch: 1 branch
BranchTrueFalseTotal
if (not $self->{"control_settings_rewritten"} and defined $self->{"control_stream_id"} and $id == $self->{"control_stream_id"} and keys %{$$self{"extension_settings"};}) 9 202 211
Condition77%7/9
not $self->{"control_settings_rewritten"} and defined $self->{"control_stream_id"} and $id == $self->{"control_stream_id"} and keys %{$$self{"extension_settings"};}
!ll&&!rl&&r
192109
not $self->{"control_settings_rewritten"} and defined $self->{"control_stream_id"} and $id == $self->{"control_stream_id"}
!ll&&!rl&&r
192019
not $self->{"control_settings_rewritten"} and defined $self->{"control_stream_id"}
!ll&&!rl&&r
192019
MC/DC50%2/4
not $self->{"control_settings_rewritten"} and defined $self->{"control_stream_id"} and $id == $self->{"control_stream_id"} and keys %{$$self{"extension_settings"};}
not $self->{"control_settings_rewritten"} defined $self->{"control_stream_id"} $id == $self->{"control_stream_id"} keys %{$$self{"extension_settings"};}
Truth table60%3/5
not(A) and B and C and D
A= not $self->{"control_settings_rewritten"}B= defined $self->{"control_stream_id"}C= $id == $self->{"control_stream_id"}D= keys %{$$self{"extension_settings"};}
ABCDresult
0XXX0
10XX0
110X0
11100
11111
4554 !$self->{control_settings_rewritten}
4555 && defined($self->{control_stream_id})
4556 && $id == $self->{control_stream_id}
4557 19 && keys %{ $self->{extension_settings} }
4558 ) {
4559 9 ▶ croak 'HTTP/3 control stream unexpectedly ended with SETTINGS'
Branch: 1 branch
BranchTrueFalseTotal
if $fin 0 9 9
4560 if $fin;
4561  
4562 my ($rewritten, $native_length, $delta) =
4563 _rewrite_control_settings(
4564 $bytes,
4565 $self->{extension_settings},
4566 9 );
4567  
4568 9 $self->{control_settings_rewritten} = 1;
4569 $self->{control_settings_pending} = {
4570 9 id => $id,
4571 bytes => $rewritten,
4572 offset => 0,
4573 native_length => $native_length,
4574 delta => $delta,
4575 };
4576 9 next;
4577 }
4578  
4579 $self->{control_settings_rewritten} = 1
4580 if defined($self->{control_stream_id})
4581 202 ▶ && $id == $self->{control_stream_id};
Branch: 1 branch
BranchTrueFalseTotal
if defined $self->{"control_stream_id"} and $id == $self->{"control_stream_id"} 11 191 202
Condition66%2/3
defined $self->{"control_stream_id"} and $id == $self->{"control_stream_id"}
!ll&&!rl&&r
019111
MC/DC50%1/2
defined $self->{"control_stream_id"} and $id == $self->{"control_stream_id"}
defined $self->{"control_stream_id"} $id == $self->{"control_stream_id"}
Truth table66%2/3
A and B
A= defined $self->{"control_stream_id"}B= $id == $self->{"control_stream_id"}
ABresult
0X0
100
111
4582  
4583 202 my $length = length($bytes);
4584 202 my $accepted = 0;
4585  
4586 202 ▶ if ($length) {
Branch: 1 branch
BranchTrueFalseTotal
if ($length) 192 10 202
4587 192 $accepted = $stream->send_some($bytes);
4588 }
4589  
4590 202 $self->{native}->add_write_offset($id, $accepted);
4591  
4592 202 ▶ if ($fin && $accepted == $length) {
Branch: 1 branch
BranchTrueFalseTotal
if ($fin and $accepted == $length) 49 153 202
Condition100%3/3
$fin and $accepted == $length
!ll&&!rl&&r
151249
MC/DC100%2/2
$fin and $accepted == $length
$fin $accepted == $length
Truth table100%3/3
A and B
A= $finB= $accepted == $length
ABresult
0X0
100
111
4593 49 $stream->finish;
4594 49 $self->{output_finished}{$id} = 1;
4595 49 $self->_maybe_complete_transaction($id);
4596 }
4597  
4598 202 ▶ last if $accepted < $length;
Branch: 1 branch
BranchTrueFalseTotal
if $accepted < $length 10 192 202
4599 192 ▶ last if !$length && !$fin;
Branch: 1 branch
BranchTrueFalseTotal
unless $length or $fin 0 192 192
Condition66%2/3
$length or $fin
l!l&&r!l&&!r
182100
MC/DC0%0/2
$length or $fin
$length $fin
Truth table66%2/3
A or B
A= $lengthB= $fin
ABresult
1X1
011
000
4600 }
4601  
4602 568 return;
4603 }
4604  
4605 18 1;
4606  
4607 __END__
↑ Summary blib/lib/Unblock/HTTP3/Capsule/Stream.pm »