blib/lib/Unblock/HTTP2/_Connection.pm

filter: Statementstmt 93.7% 404 / 431 Branchbran 70.7% 222 / 314 Conditioncond 51.9% 121 / 233 MC/DCmcdc 22.4% 29 / 129 Subroutinesub 97.9% 47 / 48 Podpod 0.0% 0 / 21 totaltotal 69.9% 823 / 1176 CC 249 SCAR 28.2
CC
249
Cov
76%
_transport_sync
43.7
_validate_settings
34.3
goaway
23.9
CRAP 16.8
« blib/lib/Unblock/HTTP2/_nghttp2.pm ↑ Summary blib/lib/Unblock/HTTP2/Transaction.pm »
1 package Unblock::HTTP2::_Connection;
2  
3 28 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 28 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 28 ▶use Carp qw(croak);
Subroutine BEGIN: called CC=1 SCAR=0.0
6 28 ▶use Scalar::Util qw(blessed weaken);
Subroutine BEGIN: called CC=1 SCAR=0.0
7 28 ▶use utf8 ();
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 28 our $VERSION = '0.11';
10  
11 28 my @SETTING_NAMES = qw(
12 header_table_size
13 enable_push
14 max_concurrent_streams
15 initial_window_size
16 max_frame_size
17 max_header_list_size
18 enable_connect_protocol
19 no_rfc7540_priorities
20 );
21  
22 28 my %SETTING_ID = (
23 header_table_size => 1,
24 enable_push => 2,
25 max_concurrent_streams => 3,
26 initial_window_size => 4,
27 max_frame_size => 5,
28 max_header_list_size => 6,
29 enable_connect_protocol => 8,
30 no_rfc7540_priorities => 9,
31 );
32  
33 28 my %SETTING_NAME = reverse %SETTING_ID;
34  
35  
36 82 ▶sub _initialize_connection {
Subroutine _initialize_connection: called CC=14 SCAR=26.9
37 82 my ($self, $session, %option) = @_;
38  
39 82 ▶ croak 'HTTP/2 session must be an object'
Branch: 1 branch
BranchTrueFalseTotal
unless builtin::blessed($session) 0 82 82
40 unless blessed($session);
41  
42 82 my $transport = delete $option{transport};
43 82 ▶ if (defined $transport) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $transport) 12 70 82
44 12 ▶ croak 'new(): transport must be an object' unless blessed($transport);
Branch: 1 branch
BranchTrueFalseTotal
unless builtin::blessed($transport) 0 12 12
45 12 for my $method (qw(unblock_send unblock_finish unblock_abort)) {
46 36 ▶ croak "new(): transport must implement $method()"
Branch: 1 branch
BranchTrueFalseTotal
unless $transport->can($method) 0 36 36
47 unless $transport->can($method);
48 }
49 }
50 82 my $role = delete $option{role};
51 82 ▶ my $callbacks = delete($option{callbacks}) || {};
Condition50%1/2
delete $option{'callbacks'} || {}
l!l
820
MC/DC0%0/1
delete $option{'callbacks'} || {}
delete $option{'callbacks'}
Truth table50%1/2
A
A= delete $option{'callbacks'}
Aresult
11
00
52  
53 82 ▶ croak 'HTTP/2 connection role must be client or server'
Branch: 1 branch
BranchTrueFalseTotal
unless defined $role and $role eq "client" || $role eq "server" 0 82 82
Condition50%3/6
defined $role and $role eq "client" || $role eq "server"
!ll&&!rl&&r
0082
$role eq "client" or $role eq "server"
l!l&&r!l&&!r
45370
MC/DC0%0/3
defined $role and $role eq "client" || $role eq "server"
defined $role $role eq "client" $role eq "server"
Truth table50%2/4
A and B or C
A= defined $roleB= $role eq "client"C= $role eq "server"
ABCresult
0XX0
1000
11X1
1011
54 unless defined($role) && ($role eq 'client' || $role eq 'server');
55 82 ▶ croak 'HTTP/2 connection callbacks must be a hash reference'
Branch: 1 branch
BranchTrueFalseTotal
unless ref $callbacks eq "HASH" 0 82 82
56 unless ref($callbacks) eq 'HASH';
57 82 ▶ croak 'unknown HTTP/2 connection options: ' . join(', ', sort keys %option)
Branch: 1 branch
BranchTrueFalseTotal
if %option 0 82 82
58 if %option;
59  
60 82 $self->{transport} = $transport;
61 82 ▶ weaken($self->{transport}) if defined $transport;
Branch: 1 branch
BranchTrueFalseTotal
if defined $transport 12 70 82
62 82 ▶ $self->{transport_attached} = defined($transport) ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
defined $transport ? : 12 70 82
63 82 $self->{transport_blocked} = 0;
64 82 $self->{transport_syncing} = 0;
65 82 $self->{transport_finished} = 0;
66 82 $self->{transport_aborted} = 0;
67 82 $self->{transport_graceful} = 0;
68 82 $self->{transport_pending} = '';
69 82 $self->{input_eof} = 0;
70 82 $self->{session} = $session;
71 82 $self->{role} = $role;
72 82 $self->{callbacks} = $callbacks;
73 82 $self->{transactions} = {};
74 82 $self->{closed} = 0;
75 82 $self->{close_reason} = undef;
76 82 $self->{in_session_call} = 0;
77 82 $self->{close_pending} = undef;
78 82 $self->{pending_drain} = {};
79 82 $self->{local_settings} = {};
80 82 $self->{peer_settings} = {};
81 82 $self->{settings_pending} = [];
82 82 $self->{local_goaway} = undef;
83  
84 82 $self->_refresh_peer_settings;
85 82 return $self;
86 }
87  
88 109 ▶sub is_closed {
Subroutine is_closed: called CC=2 SCAR=6.9
Pod undocumented
89 109 ▶ return $_[0]{closed} ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$_[0]{'closed'} ? : 13 96 109
90 }
91  
92 4 ▶sub close_reason {
Subroutine close_reason: called CC=1 SCAR=0.0
Pod undocumented
93 4 return $_[0]{close_reason};
94 }
95  
96 45 ▶sub transaction_count {
Subroutine transaction_count: called CC=1 SCAR=0.0
Pod undocumented
97 45 return scalar keys %{ $_[0]{transactions} };
98 }
99  
100 218 ▶sub transaction_for_stream_id {
Subroutine transaction_for_stream_id: called CC=1 SCAR=0.0
Pod undocumented
101 218 my ($self, $stream_id) = @_;
102 218 return $self->{transactions}{$stream_id};
103 }
104  
105 1 ▶sub want_read {
Subroutine want_read: called CC=5 SCAR=23.8
Pod undocumented
106 1 my ($self) = @_;
107 1 ▶ return 0 if $self->{closed} || !$self->{session} || $self->{input_eof};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"closed"} or not $self->{"session"} or $self->{"input_eof"} 1 0 1
Condition33%2/6
$self->{"closed"} or not $self->{"session"} or $self->{"input_eof"}
l!l&&r!l&&!r
100
$self->{"closed"} or not $self->{"session"}
l!l&&r!l&&!r
100
MC/DC0%0/3
$self->{"closed"} or not $self->{"session"} or $self->{"input_eof"}
$self->{"closed"} not $self->{"session"} $self->{"input_eof"}
Truth table25%1/4
A or not(B) or C
A= $self->{"closed"}B= not $self->{"session"}C= $self->{"input_eof"}
ABCresult
1XX1
01X1
0011
0000
108 0 ▶ return $self->{session}->want_read ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$self->{'session'}->want_read ? : 0 0 0
109 }
110  
111 435 ▶sub want_write {
Subroutine want_write: called CC=4 SCAR=13.9
Pod undocumented
112 435 my ($self) = @_;
113 435 ▶ return 0 if $self->{closed} || !$self->{session};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"closed"} or not $self->{"session"} 2 433 435
Condition66%2/3
$self->{"closed"} or not $self->{"session"}
l!l&&r!l&&!r
20433
MC/DC50%1/2
$self->{"closed"} or not $self->{"session"}
$self->{"closed"} not $self->{"session"}
Truth table66%2/3
A or not(B)
A= $self->{"closed"}B= not $self->{"session"}
ABresult
1X1
011
000
114 433 ▶ return $self->{session}->want_write ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$self->{'session'}->want_write ? : 160 273 433
115 }
116  
117 176 ▶sub input {
Subroutine input: called CC=15 SCAR=29.2
Pod undocumented
118 176 my ($self, $bytes) = @_;
119  
120 176 ▶ croak 'input(): connection is closed' if $self->{closed};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"closed"} 1 175 176
121 175 ▶ croak 'input(): read side is already at EOF' if $self->{input_eof};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"input_eof"} 0 175 175
122 croak 'input(): cannot be called from unblock_send()'
123 175 ▶ if $self->{transport_syncing};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"transport_syncing"} 1 174 175
124 174 ▶ croak 'input(): bytes must be a scalar' if ref($bytes);
Branch: 1 branch
BranchTrueFalseTotal
if ref $bytes 0 174 174
125 174 ▶ return 0 unless defined($bytes) && length($bytes);
Branch: 1 branch
BranchTrueFalseTotal
unless defined $bytes and length $bytes 0 174 174
Condition33%1/3
defined $bytes and length $bytes
!ll&&!rl&&r
00174
MC/DC0%0/2
defined $bytes and length $bytes
defined $bytes length $bytes
Truth table33%1/3
A and B
A= defined $bytesB= length $bytes
ABresult
0X0
100
111
126 croak 'input(): cannot be called from an HTTP/2 session callback'
127 174 ▶ if $self->{in_session_call};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"in_session_call"} 0 174 174
128  
129 174 my $consumed;
130 174 my $ok = eval {
131 174 local $self->{in_session_call} = 1;
132 174 $consumed = $self->{session}->mem_recv($bytes);
133 173 1;
134 };
135  
136 174 ▶ if (!$ok) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($ok) 1 173 174
137 1 ▶ my $error = length($@) ? "$@" : 'input(): nghttp2 receive failed';
Branch: 1 branch
BranchTrueFalseTotal
length $@ ? : 1 0 1
138 1 ▶ $self->_finish_close($error) unless $self->{closed};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"closed"} 1 0 1
139 1 die $error;
140 }
141  
142 173 ▶ if (!defined($consumed) || $consumed != length($bytes)) {
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $consumed or $consumed != length $bytes) 0 173 173
Condition33%1/3
not defined $consumed or $consumed != length $bytes
l!l&&r!l&&!r
00173
MC/DC0%0/2
not defined $consumed or $consumed != length $bytes
not defined $consumed $consumed != length $bytes
Truth table33%1/3
not(A) or B
A= not defined $consumedB= $consumed != length $bytes
ABresult
1X1
011
000
143 0 my $error = 'input(): nghttp2 did not consume complete input';
144 0 $self->_finish_close($error);
145 0 croak $error;
146 }
147  
148 173 ▶ if (defined $self->{close_pending}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->{"close_pending"}) 4 169 173
149 4 $self->_finish_close(delete $self->{close_pending});
150 4 return $consumed;
151 }
152  
153 169 $self->_after_session_call;
154 169 ▶ $self->_transport_sync if $self->{transport_attached};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"transport_attached"} 9 160 169
155 169 return $consumed;
156 }
157  
158 159 ▶sub output {
Subroutine output: called CC=2 SCAR=6.9
Pod undocumented
159 159 my ($self) = @_;
160 croak 'output(): manual output is unavailable with an attached transport'
161 159 ▶ if $self->{transport_attached};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"transport_attached"} 1 158 159
162 158 return $self->_output_raw;
163 }
164  
165 183 ▶sub _output_raw {
Subroutine _output_raw: called CC=10 SCAR=29.8
166 183 my ($self) = @_;
167  
168 183 ▶ croak 'output(): connection is closed' if $self->{closed};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"closed"} 0 183 183
169 croak 'output(): cannot be called from an HTTP/2 session callback'
170 183 ▶ if $self->{in_session_call};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"in_session_call"} 0 183 183
171  
172 183 ▶ return '' unless $self->{session}->want_write;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"session"}->want_write 0 183 183
173  
174 183 my $bytes;
175 183 my $ok = eval {
176 183 local $self->{in_session_call} = 1;
177 183 $bytes = $self->{session}->mem_send;
178 183 1;
179 };
180  
181 183 ▶ if (!$ok) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($ok) 0 183 183
182 0 ▶ my $error = length($@) ? "$@" : 'output(): nghttp2 send failed';
Branch: 1 branch
BranchTrueFalseTotal
length $@ ? : 0 0 0
183 0 ▶ $self->_finish_close($error) unless $self->{closed};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"closed"} 0 0 0
184 0 die $error;
185 }
186  
187 183 ▶ if (defined $self->{close_pending}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->{"close_pending"}) 0 183 183
188 0 $self->_finish_close(delete $self->{close_pending});
189 0 ▶ return defined($bytes) ? $bytes : '';
Branch: 1 branch
BranchTrueFalseTotal
defined $bytes ? : 0 0 0
190 }
191  
192 183 ▶ $bytes = '' unless defined $bytes;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $bytes 0 183 183
193  
194 183 $self->_after_session_call;
195 183 return $bytes;
196 }
197  
198  
199 # nghttp2 generates wire buffers on demand. An attached transport accepts
200 # each complete buffer into its own output queue before reporting congestion.
201 43 ▶sub _transport_sync {
Subroutine _transport_sync: called CC=29 SCAR=37.8
202 43 my ($self) = @_;
203 43 ▶ return unless $self->{transport_attached};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"transport_attached"} 0 43 43
204 43 ▶ return if $self->{transport_syncing} || $self->{in_session_call};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"transport_syncing"} or $self->{"in_session_call"} 2 41 43
Condition66%2/3
$self->{"transport_syncing"} or $self->{"in_session_call"}
l!l&&r!l&&!r
0241
MC/DC50%1/2
$self->{"transport_syncing"} or $self->{"in_session_call"}
$self->{"transport_syncing"} $self->{"in_session_call"}
Truth table66%2/3
A or B
A= $self->{"transport_syncing"}B= $self->{"in_session_call"}
ABresult
1X1
011
000
205 41 ▶ return if $self->{transport_aborted} || $self->{transport_finished};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"transport_aborted"} or $self->{"transport_finished"} 0 41 41
Condition33%1/3
$self->{"transport_aborted"} or $self->{"transport_finished"}
l!l&&r!l&&!r
0041
MC/DC0%0/2
$self->{"transport_aborted"} or $self->{"transport_finished"}
$self->{"transport_aborted"} $self->{"transport_finished"}
Truth table33%1/3
A or B
A= $self->{"transport_aborted"}B= $self->{"transport_finished"}
ABresult
1X1
011
000
206 41 ▶ return if $self->{transport_blocked};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"transport_blocked"} 3 38 41
207  
208 38 my $host = $self->{transport};
209 38 ▶ return $self->_transport_abort('HTTP/2 transport was destroyed')
Branch: 1 branch
BranchTrueFalseTotal
unless $host 1 37 38
210 unless $host;
211  
212 {
213 37 local $self->{transport_syncing} = 1;
214 37 ▶ while (!$self->{transport_blocked}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"transport_blocked"}) 58 2 60
215 58 my $bytes;
216 58 ▶ if (length $self->{transport_pending}) {
Branch: 2 branches
BranchTrueFalseTotal
if (length $self->{'transport_pending'}) { } 0 58 58
elsif (not $self->{'closed'} and $self->{'session'} and $self->{'session'}->want_write) { } 25 33 58
217 0 $bytes = $self->{transport_pending};
218 0 $self->{transport_pending} = '';
219 }
220 ▶ elsif (!$self->{closed} && $self->{session}
Condition83%5/6
not $self->{"closed"} and $self->{"session"} and $self->{"session"}->want_write
!ll&&!rl&&r
42925
not $self->{"closed"} and $self->{"session"}
!ll&&!rl&&r
4054
MC/DC66%2/3
not $self->{"closed"} and $self->{"session"} and $self->{"session"}->want_write
not $self->{"closed"} $self->{"session"} $self->{"session"}->want_write
Truth table75%3/4
not(A) and B and C
A= not $self->{"closed"}B= $self->{"session"}C= $self->{"session"}->want_write
ABCresult
0XX0
10X0
1100
1111
221 && $self->{session}->want_write) {
222 25 my $ok = eval { $bytes = $self->_output_raw; 1 };
223 25 ▶ unless ($ok) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($ok) 0 25 25
224 0 ▶ $self->_transport_abort("$@" || 'HTTP/2 output failed');
Condition0%0/2
"$@" || 'HTTP/2 output failed'
l!l
00
MC/DC0%0/1
"$@" || 'HTTP/2 output failed'
"$@"
Truth table0%0/2
A
A= "$@"
Aresult
11
00
225 0 return;
226 }
227 }
228 else {
229 33 last;
230 }
231 25 ▶ last unless defined($bytes) && length($bytes);
Branch: 1 branch
BranchTrueFalseTotal
unless defined $bytes and length $bytes 0 25 25
Condition33%1/3
defined $bytes and length $bytes
!ll&&!rl&&r
0025
MC/DC0%0/2
defined $bytes and length $bytes
defined $bytes length $bytes
Truth table33%1/3
A and B
A= defined $bytesB= length $bytes
ABresult
0X0
100
111
232  
233 25 my $ready;
234 25 my $ok = eval { $ready = $host->unblock_send($bytes); 1 };
235 25 ▶ unless ($ok) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($ok) 2 23 25
236 2 ▶ $self->_transport_abort("$@" || 'unblock_send() failed');
Condition50%1/2
"$@" || 'unblock_send() failed'
l!l
20
MC/DC0%0/1
"$@" || 'unblock_send() failed'
"$@"
Truth table50%1/2
A
A= "$@"
Aresult
11
00
237 2 return;
238 }
239 23 ▶ $self->{transport_blocked} = 1 if defined($ready) && !$ready;
Branch: 1 branch
BranchTrueFalseTotal
if defined $ready and not $ready 2 21 23
Condition66%2/3
defined $ready and not $ready
!ll&&!rl&&r
2102
MC/DC50%1/2
defined $ready and not $ready
defined $ready not $ready
Truth table66%2/3
A and not(B)
A= defined $readyB= not $ready
ABresult
0X0
100
111
240 }
241 }
242  
243 35 ▶ if ($self->{closed} && $self->{transport_graceful}
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"closed"} and $self->{"transport_graceful"} and not length $self->{"transport_pending"} and not $self->{"transport_blocked"} and not $self->{"transport_finished"} and not $self->{"transport_aborted"}) 4 31 35
Condition66%10/15
$self->{"closed"} and $self->{"transport_graceful"} and not length $self->{"transport_pending"} and not $self->{"transport_blocked"} and not $self->{"transport_finished"} and not $self->{"transport_aborted"}
!ll&&!rl&&r
3104
$self->{"closed"} and $self->{"transport_graceful"} and not length $self->{"transport_pending"} and not $self->{"transport_blocked"} and not $self->{"transport_finished"}
!ll&&!rl&&r
3104
$self->{"closed"} and $self->{"transport_graceful"} and not length $self->{"transport_pending"} and not $self->{"transport_blocked"}
!ll&&!rl&&r
3104
$self->{"closed"} and $self->{"transport_graceful"} and not length $self->{"transport_pending"}
!ll&&!rl&&r
3104
$self->{"closed"} and $self->{"transport_graceful"}
!ll&&!rl&&r
3104
MC/DC16%1/6
$self->{"closed"} and $self->{"transport_graceful"} and not length $self->{"transport_pending"} and not $self->{"transport_blocked"} and not $self->{"transport_finished"} and not $self->{"transport_aborted"}
$self->{"closed"} $self->{"transport_graceful"} not length $self->{"transport_pending"} not $self->{"transport_blocked"} not $self->{"transport_finished"} not $self->{"transport_aborted"}
Truth table28%2/7
A and B and not(C) and not(D) and not(E) and not(F)
A= $self->{"closed"}B= $self->{"transport_graceful"}C= not length $self->{"transport_pending"}D= not $self->{"transport_blocked"}E= not $self->{"transport_finished"}F= not $self->{"transport_aborted"}
ABCDEFresult
0XXXXX0
10XXXX0
110XXX0
1110XX0
11110X0
1111100
1111111
244 && !length($self->{transport_pending})
245 && !$self->{transport_blocked}
246 && !$self->{transport_finished}
247 && !$self->{transport_aborted}) {
248 4 $self->{transport_finished} = 1;
249 4 my $ok = eval { $host->unblock_finish(); 1 };
250 4 ▶ $self->_transport_abort("$@" || 'unblock_finish() failed') unless $ok;
Branch: 1 branch
BranchTrueFalseTotal
unless $ok 0 4 4
Condition0%0/2
"$@" || 'unblock_finish() failed'
l!l
00
MC/DC0%0/1
"$@" || 'unblock_finish() failed'
"$@"
Truth table0%0/2
A
A= "$@"
Aresult
11
00
251 }
252 35 return;
253 }
254  
255 2 ▶sub resume_output {
Subroutine resume_output: called CC=11 SCAR=27.9
Pod undocumented
256 2 my ($self) = @_;
257 croak 'resume_output(): no attached transport'
258 2 ▶ unless $self->{transport_attached};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"transport_attached"} 0 2 2
259 croak 'resume_output(): cannot be called from unblock_send()'
260 2 ▶ if $self->{transport_syncing};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"transport_syncing"} 0 2 2
261 2 ▶ return $self if $self->{transport_finished} || $self->{transport_aborted};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"transport_finished"} or $self->{"transport_aborted"} 0 2 2
Condition33%1/3
$self->{"transport_finished"} or $self->{"transport_aborted"}
l!l&&r!l&&!r
002
MC/DC0%0/2
$self->{"transport_finished"} or $self->{"transport_aborted"}
$self->{"transport_finished"} $self->{"transport_aborted"}
Truth table33%1/3
A or B
A= $self->{"transport_finished"}B= $self->{"transport_aborted"}
ABresult
1X1
011
000
262 2 $self->{transport_blocked} = 0;
263 2 $self->_transport_sync;
264 2 ▶ if (!$self->{transport_blocked} && !$self->{closed}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"transport_blocked"} or $self->{"closed"}) 1 1 2
Condition66%2/3
$self->{"transport_blocked"} or $self->{"closed"}
l!l&&r!l&&!r
011
MC/DC50%1/2
$self->{"transport_blocked"} or $self->{"closed"}
$self->{"transport_blocked"} $self->{"closed"}
Truth table66%2/3
A or B
A= $self->{"transport_blocked"}B= $self->{"closed"}
ABresult
1X1
011
000
265 # Producers can have paused because the host, rather than their own
266 # stream queue, was congested. Wake only those below low water.
267 1 ▶ for my $id (keys %{ $self->{providers} || {} }) {
Condition50%1/2
$self->{'providers'} || {}
l!l
10
MC/DC0%0/1
$self->{'providers'} || {}
$self->{'providers'}
Truth table50%1/2
A
A= $self->{'providers'}
Aresult
11
00
268 1 my $provider = $self->{providers}{$id};
269 1 ▶ next unless $provider->{blocked};
Branch: 1 branch
BranchTrueFalseTotal
unless $provider->{"blocked"} 1 0 1
270 0 ▶ next unless length($provider->{queue}) < 32_768;
Branch: 1 branch
BranchTrueFalseTotal
unless length $provider->{"queue"} < 32768 0 0 0
271 0 $provider->{blocked} = 0;
272 0 $self->_queue_drain($id);
273 }
274 1 $self->_after_session_call;
275 1 $self->_transport_sync;
276 }
277 2 return $self;
278 }
279  
280 7 ▶sub _transport_abort {
Subroutine _transport_abort: called CC=4 SCAR=13.9
281 7 my ($self, $reason) = @_;
282 7 ▶ return if $self->{transport_aborted};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"transport_aborted"} 2 5 7
283 5 $self->{transport_aborted} = 1;
284 5 $self->{transport_pending} = '';
285 5 $self->{transport_graceful} = 0;
286 5 ▶ $self->_finish_close($reason) unless $self->{closed};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"closed"} 4 1 5
287 5 ▶ if (my $host = $self->{transport}) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $host = $self->{"transport"}) 4 1 5
288 4 eval { $host->unblock_abort($reason) };
289 }
290 5 return;
291 }
292  
293 3 ▶sub transport_error {
Subroutine transport_error: called CC=3 SCAR=12.0
Pod undocumented
294 3 my ($self, $reason) = @_;
295 3 ▶ $reason = 'transport error' unless defined($reason) && length($reason);
Branch: 1 branch
BranchTrueFalseTotal
unless defined $reason and length $reason 0 3 3
Condition33%1/3
defined $reason and length $reason
!ll&&!rl&&r
003
MC/DC0%0/2
defined $reason and length $reason
defined $reason length $reason
Truth table33%1/3
A and B
A= defined $reasonB= length $reason
ABresult
0X0
100
111
296 3 $self->_transport_abort("$reason");
297 3 return $self;
298 }
299  
300 3 ▶sub input_eof {
Subroutine input_eof: called CC=5 SCAR=16.4
Pod undocumented
301 3 my ($self) = @_;
302 3 ▶ return $self if $self->{input_eof} || $self->{closed};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"input_eof"} or $self->{"closed"} 2 1 3
Condition100%3/3
$self->{"input_eof"} or $self->{"closed"}
l!l&&r!l&&!r
111
MC/DC100%2/2
$self->{"input_eof"} or $self->{"closed"}
$self->{"input_eof"} $self->{"closed"}
Truth table100%3/3
A or B
A= $self->{"input_eof"}B= $self->{"closed"}
ABresult
1X1
011
000
303 croak 'input_eof(): cannot be called during HTTP/2 input or host send'
304 1 ▶ if $self->{in_session_call} || $self->{transport_syncing};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"in_session_call"} or $self->{"transport_syncing"} 0 1 1
Condition33%1/3
$self->{"in_session_call"} or $self->{"transport_syncing"}
l!l&&r!l&&!r
001
MC/DC0%0/2
$self->{"in_session_call"} or $self->{"transport_syncing"}
$self->{"in_session_call"} $self->{"transport_syncing"}
Truth table33%1/3
A or B
A= $self->{"in_session_call"}B= $self->{"transport_syncing"}
ABresult
1X1
011
000
305 1 $self->{input_eof} = 1;
306 # Unlike HTTP/1, EOF never completes an HTTP/2 response body.
307 1 $self->close('HTTP/2 transport reached EOF');
308 1 return $self;
309 }
310  
311 # Retain unsent wire output across explicit close, even while a host is paused.
312 4 ▶sub _stage_final_output {
Subroutine _stage_final_output: called CC=8 SCAR=30.1
313 4 my ($self) = @_;
314 4 ▶ return unless $self->{transport_attached} && $self->{session};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"transport_attached"} and $self->{"session"} 0 4 4
Condition33%1/3
$self->{"transport_attached"} and $self->{"session"}
!ll&&!rl&&r
004
MC/DC0%0/2
$self->{"transport_attached"} and $self->{"session"}
$self->{"transport_attached"} $self->{"session"}
Truth table33%1/3
A and B
A= $self->{"transport_attached"}B= $self->{"session"}
ABresult
0X0
100
111
315 4 ▶ return if $self->{staging_final_output};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"staging_final_output"} 0 4 4
316 4 local $self->{staging_final_output} = 1;
317 4 ▶ while ($self->{session} && $self->{session}->want_write) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"session"} and $self->{"session"}->want_write) 0 4 4
Condition33%1/3
$self->{"session"} and $self->{"session"}->want_write
!ll&&!rl&&r
040
MC/DC0%0/2
$self->{"session"} and $self->{"session"}->want_write
$self->{"session"} $self->{"session"}->want_write
Truth table33%1/3
A and B
A= $self->{"session"}B= $self->{"session"}->want_write
ABresult
0X0
100
111
318 0 my $bytes = $self->_output_raw;
319 0 ▶ last unless defined($bytes) && length($bytes);
Branch: 1 branch
BranchTrueFalseTotal
unless defined $bytes and length $bytes 0 0 0
Condition0%0/3
defined $bytes and length $bytes
!ll&&!rl&&r
000
MC/DC0%0/2
defined $bytes and length $bytes
defined $bytes length $bytes
Truth table0%0/3
A and B
A= defined $bytesB= length $bytes
ABresult
0X0
100
111
320 0 $self->{transport_pending} .= $bytes;
321 }
322 4 return;
323 }
324  
325 68 ▶sub _register_transaction {
Subroutine _register_transaction: called CC=1 SCAR=0.0
326 68 my ($self, $transaction) = @_;
327 68 $self->{transactions}{ $transaction->stream_id } = $transaction;
328 68 return $transaction;
329 }
330  
331 60 ▶sub _remove_transaction {
Subroutine _remove_transaction: called CC=1 SCAR=0.0
332 60 my ($self, $stream_id) = @_;
333 60 delete $self->{pending_drain}{$stream_id};
334 60 return delete $self->{transactions}{$stream_id};
335 }
336  
337 3 ▶sub _queue_drain {
Subroutine _queue_drain: called CC=1 SCAR=0.0
338 3 my ($self, $stream_id) = @_;
339 3 $self->{pending_drain}{$stream_id} = 1;
340 3 return;
341 }
342  
343 3 ▶sub _reset_stream {
Subroutine _reset_stream: called CC=8 SCAR=26.0
344 3 my ($self, $transaction, $error_code) = @_;
345  
346 croak 'reset(): connection is closed'
347 3 ▶ if $self->{closed} || !$self->{session};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"closed"} or not $self->{"session"} 0 3 3
Condition33%1/3
$self->{"closed"} or not $self->{"session"}
l!l&&r!l&&!r
003
MC/DC0%0/2
$self->{"closed"} or not $self->{"session"}
$self->{"closed"} not $self->{"session"}
Truth table33%1/3
A or not(B)
A= $self->{"closed"}B= not $self->{"session"}
ABresult
1X1
011
000
348 3 ▶ croak 'reset(): error code must be an unsigned 32-bit integer'
Branch: 1 branch
BranchTrueFalseTotal
unless defined $error_code and not ref $error_code and "$error_code" =~ /\A[0-9]+\z/ and $error_code <= 4294967295 0 3 3
Condition33%3/9
defined $error_code and not ref $error_code and "$error_code" =~ /\A[0-9]+\z/ and $error_code <= 4294967295
!ll&&!rl&&r
003
defined $error_code and not ref $error_code and "$error_code" =~ /\A[0-9]+\z/
!ll&&!rl&&r
003
defined $error_code and not ref $error_code
!ll&&!rl&&r
003
MC/DC0%0/4
defined $error_code and not ref $error_code and "$error_code" =~ /\A[0-9]+\z/ and $error_code <= 4294967295
defined $error_code not ref $error_code "$error_code" =~ /\A[0-9]+\z/ $error_code <= 4294967295
Truth table20%1/5
A and not(B) and C and D
A= defined $error_codeB= not ref $error_codeC= "$error_code" =~ /\A[0-9]+\z/D= $error_code <= 4294967295
ABCDresult
0XXX0
10XX0
110X0
11100
11111
349 unless defined($error_code) && !ref($error_code)
350 && "$error_code" =~ /\A[0-9]+\z/
351 && $error_code <= 4_294_967_295;
352  
353 3 $self->{session}->submit_rst_stream($transaction->stream_id, 0 + $error_code);
354 3 $transaction->_mark_cancelled(0 + $error_code, 0);
355 3 ▶ $self->_transport_sync if $self->{transport_attached};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"transport_attached"} 0 3 3
356 3 return;
357 }
358  
359 52 ▶sub _consume_stream_body {
Subroutine _consume_stream_body: called CC=5 SCAR=17.0
360 52 my ($self, $transaction, $bytes) = @_;
361  
362 croak 'consume(): connection is closed'
363 52 ▶ if $self->{closed} || !$self->{session};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"closed"} or not $self->{"session"} 0 52 52
Condition33%1/3
$self->{"closed"} or not $self->{"session"}
l!l&&r!l&&!r
0052
MC/DC0%0/2
$self->{"closed"} or not $self->{"session"}
$self->{"closed"} not $self->{"session"}
Truth table33%1/3
A or not(B)
A= $self->{"closed"}B= not $self->{"session"}
ABresult
1X1
011
000
364 52 ▶ return unless $bytes;
Branch: 1 branch
BranchTrueFalseTotal
unless $bytes 0 52 52
365  
366 52 $self->{session}->consume_stream($transaction->stream_id, $bytes);
367 52 ▶ $self->_transport_sync if $self->{transport_attached};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"transport_attached"} 2 50 52
368 52 return;
369 }
370  
371 2 ▶sub local_goaway {
Subroutine local_goaway: called CC=2 SCAR=7.0
Pod undocumented
372 2 my ($self) = @_;
373 2 ▶ return unless $self->{local_goaway};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"local_goaway"} 0 2 2
374 2 return { %{ $self->{local_goaway} } };
375 }
376  
377 12 ▶sub goaway {
Subroutine goaway: called CC=21 SCAR=31.7
Pod undocumented
378 12 my ($self, %option) = @_;
379  
380 croak 'goaway(): connection is closed'
381 12 ▶ if $self->{closed} || !$self->{session};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"closed"} or not $self->{"session"} 0 12 12
Condition33%1/3
$self->{"closed"} or not $self->{"session"}
l!l&&r!l&&!r
0012
MC/DC0%0/2
$self->{"closed"} or not $self->{"session"}
$self->{"closed"} not $self->{"session"}
Truth table33%1/3
A or not(B)
A= $self->{"closed"}B= not $self->{"session"}
ABresult
1X1
011
000
382  
383 my $error_code = exists($option{error_code})
384 ? delete($option{error_code})
385 12 ▶ : 0;
Branch: 1 branch
BranchTrueFalseTotal
exists $option{'error_code'} ? : 8 4 12
386 12 ▶ croak 'goaway(): error code must be an unsigned 32-bit integer'
Branch: 1 branch
BranchTrueFalseTotal
unless defined $error_code and not ref $error_code and "$error_code" =~ /\A[0-9]+\z/ and $error_code <= 4294967295 2 10 12
Condition66%6/9
defined $error_code and not ref $error_code and "$error_code" =~ /\A[0-9]+\z/ and $error_code <= 4294967295
!ll&&!rl&&r
1110
defined $error_code and not ref $error_code and "$error_code" =~ /\A[0-9]+\z/
!ll&&!rl&&r
0111
defined $error_code and not ref $error_code
!ll&&!rl&&r
0012
MC/DC50%2/4
defined $error_code and not ref $error_code and "$error_code" =~ /\A[0-9]+\z/ and $error_code <= 4294967295
defined $error_code not ref $error_code "$error_code" =~ /\A[0-9]+\z/ $error_code <= 4294967295
Truth table60%3/5
A and not(B) and C and D
A= defined $error_codeB= not ref $error_codeC= "$error_code" =~ /\A[0-9]+\z/D= $error_code <= 4294967295
ABCDresult
0XXX0
10XX0
110X0
11100
11111
387 unless defined($error_code) && !ref($error_code)
388 && "$error_code" =~ /\A[0-9]+\z/
389 && $error_code <= 4_294_967_295;
390  
391 my $last_stream_id = exists($option{last_stream_id})
392 ? delete($option{last_stream_id})
393 : $self->{role} eq 'server'
394 10 ▶ ? 0 + ($self->{last_peer_stream_id} || 0)
Branch: 2 branches
BranchTrueFalseTotal
exists $option{'last_stream_id'} ? : 4 6 10
$self->{'role'} eq 'server' ? : 2 4 6
Condition50%1/2
$self->{'last_peer_stream_id'} || 0
l!l
20
MC/DC0%0/1
$self->{'last_peer_stream_id'} || 0
$self->{'last_peer_stream_id'}
Truth table50%1/2
A
A= $self->{'last_peer_stream_id'}
Aresult
11
00
395 : 0;
396  
397 10 ▶ croak 'goaway(): last_stream_id must be in the HTTP/2 31-bit range'
Branch: 1 branch
BranchTrueFalseTotal
unless defined $last_stream_id and not ref $last_stream_id and "$last_stream_id" =~ /\A[0-9]+\z/ and $last_stream_id <= 2147483647 2 8 10
Condition66%6/9
defined $last_stream_id and not ref $last_stream_id and "$last_stream_id" =~ /\A[0-9]+\z/ and $last_stream_id <= 2147483647
!ll&&!rl&&r
118
defined $last_stream_id and not ref $last_stream_id and "$last_stream_id" =~ /\A[0-9]+\z/
!ll&&!rl&&r
019
defined $last_stream_id and not ref $last_stream_id
!ll&&!rl&&r
0010
MC/DC50%2/4
defined $last_stream_id and not ref $last_stream_id and "$last_stream_id" =~ /\A[0-9]+\z/ and $last_stream_id <= 2147483647
defined $last_stream_id not ref $last_stream_id "$last_stream_id" =~ /\A[0-9]+\z/ $last_stream_id <= 2147483647
Truth table60%3/5
A and not(B) and C and D
A= defined $last_stream_idB= not ref $last_stream_idC= "$last_stream_id" =~ /\A[0-9]+\z/D= $last_stream_id <= 2147483647
ABCDresult
0XXX0
10XX0
110X0
11100
11111
398 unless defined($last_stream_id) && !ref($last_stream_id)
399 && "$last_stream_id" =~ /\A[0-9]+\z/
400 && $last_stream_id <= 2_147_483_647;
401  
402 my $debug_data = exists($option{debug_data})
403 ? delete($option{debug_data})
404 8 ▶ : '';
Branch: 1 branch
BranchTrueFalseTotal
exists $option{'debug_data'} ? : 4 4 8
405 8 $debug_data = $self->_body_bytes('goaway()', $debug_data);
406  
407 7 ▶ croak 'goaway(): unknown options: ' . join(', ', sort keys %option)
Branch: 1 branch
BranchTrueFalseTotal
if %option 0 7 7
408 if %option;
409  
410 7 ▶ if ($self->{local_goaway}
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"local_goaway"} and $last_stream_id > $self->{"local_goaway"}{"last_stream_id"}) 1 6 7
Condition100%3/3
$self->{"local_goaway"} and $last_stream_id > $self->{"local_goaway"}{"last_stream_id"}
!ll&&!rl&&r
511
MC/DC100%2/2
$self->{"local_goaway"} and $last_stream_id > $self->{"local_goaway"}{"last_stream_id"}
$self->{"local_goaway"} $last_stream_id > $self->{"local_goaway"}{"last_stream_id"}
Truth table100%3/3
A and B
A= $self->{"local_goaway"}B= $last_stream_id > $self->{"local_goaway"}{"last_stream_id"}
ABresult
0X0
100
111
411 && $last_stream_id > $self->{local_goaway}{last_stream_id}) {
412 1 croak 'goaway(): last_stream_id cannot increase across GOAWAY frames';
413 }
414  
415 $self->{session}->submit_goaway(
416 6 last_stream_id => 0 + $last_stream_id,
417 error_code => 0 + $error_code,
418 debug_data => $debug_data,
419 );
420  
421 $self->{local_goaway} = {
422 6 last_stream_id => 0 + $last_stream_id,
423 error_code => 0 + $error_code,
424 debug_data => $debug_data,
425 };
426 6 ▶ $self->{draining} = 1 if exists $self->{draining};
Branch: 1 branch
BranchTrueFalseTotal
if exists $self->{"draining"} 6 0 6
427 6 ▶ $self->_transport_sync if $self->{transport_attached};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"transport_attached"} 1 5 6
428  
429 6 return $self;
430 }
431  
432 12 ▶sub ping {
Subroutine ping: called CC=6 SCAR=17.9
Pod undocumented
433 12 my ($self, $opaque) = @_;
434  
435 croak 'ping(): connection is closed'
436 12 ▶ if $self->{closed} || !$self->{session};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"closed"} or not $self->{"session"} 1 11 12
Condition66%2/3
$self->{"closed"} or not $self->{"session"}
l!l&&r!l&&!r
1011
MC/DC50%1/2
$self->{"closed"} or not $self->{"session"}
$self->{"closed"} not $self->{"session"}
Truth table66%2/3
A or not(B)
A= $self->{"closed"}B= not $self->{"session"}
ABresult
1X1
011
000
437 11 ▶ croak 'ping(): opaque data is required'
Branch: 1 branch
BranchTrueFalseTotal
unless defined $opaque 1 10 11
438 unless defined $opaque;
439  
440 10 my $bytes = $self->_body_bytes('ping()', $opaque);
441 9 ▶ croak 'ping(): opaque data must be exactly 8 bytes'
Branch: 1 branch
BranchTrueFalseTotal
unless length $bytes == 8 3 6 9
442 unless length($bytes) == 8;
443  
444 6 $self->{session}->submit_ping($bytes);
445 6 ▶ $self->_transport_sync if $self->{transport_attached};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"transport_attached"} 3 3 6
446 6 return $self;
447 }
448  
449 158 ▶sub _handle_ping_frame {
Subroutine _handle_ping_frame: called CC=6 SCAR=18.0
450 158 my ($self, $frame) = @_;
451 158 ▶ return 0 unless (($frame->{type} // -1) == 6);
Branch: 1 branch
BranchTrueFalseTotal
unless ($frame->{"type"} // -1) == 6 152 6 158
Condition50%1/2
$frame->{"type"} // -1
l!l
1580
MC/DC0%0/1
$frame->{"type"} // -1
$frame->{"type"}
Truth table50%1/2
A
A= $frame->{"type"}
Aresult
11
00
452  
453 my $opaque = defined($frame->{opaque_data})
454 6 ▶ ? "$frame->{opaque_data}"
Branch: 1 branch
BranchTrueFalseTotal
defined $frame->{'opaque_data'} ? : 6 0 6
455 : '';
456  
457 6 ▶ my $callback = (($frame->{flags} || 0) & 0x1)
Branch: 1 branch
BranchTrueFalseTotal
($frame->{'flags'} || 0) & 1 ? : 3 3 6
Condition100%2/2
$frame->{'flags'} || 0
l!l
33
MC/DC100%1/1
$frame->{'flags'} || 0
$frame->{'flags'}
Truth table100%2/2
A
A= $frame->{'flags'}
Aresult
11
00
458 ? 'on_ping_ack'
459 : 'on_ping';
460  
461 6 $self->_invoke_control_callback($callback, $opaque);
462 6 return 1;
463 }
464  
465 4 ▶sub _update_stream_priority {
Subroutine _update_stream_priority: called CC=7 SCAR=20.2
466 4 my ($self, $transaction, $field_value) = @_;
467  
468 croak 'update_priority(): connection is closed'
469 4 ▶ if $self->{closed} || !$self->{session};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"closed"} or not $self->{"session"} 0 4 4
Condition33%1/3
$self->{"closed"} or not $self->{"session"}
l!l&&r!l&&!r
004
MC/DC0%0/2
$self->{"closed"} or not $self->{"session"}
$self->{"closed"} not $self->{"session"}
Truth table33%1/3
A or not(B)
A= $self->{"closed"}B= not $self->{"session"}
ABresult
1X1
011
000
470 croak 'update_priority(): only clients can send PRIORITY_UPDATE'
471 4 ▶ unless $self->{role} eq 'client';
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"role"} eq "client" 0 4 4
472  
473 4 my $bytes = $self->_body_bytes('update_priority()', $field_value);
474 3 ▶ croak 'update_priority(): field value exceeds HTTP/2 PRIORITY_UPDATE limit'
Branch: 1 branch
BranchTrueFalseTotal
if length $bytes > 16380 1 2 3
475 if length($bytes) > 16_380;
476  
477 2 my $enabled = $self->peer_setting('no_rfc7540_priorities');
478 2 ▶ croak 'update_priority(): peer has not enabled RFC 9218 priorities'
Branch: 1 branch
BranchTrueFalseTotal
unless $enabled == 1 1 1 2
479 unless $enabled == 1;
480  
481 1 $self->{session}->submit_priority_update($transaction->stream_id, $bytes);
482 1 ▶ $self->_transport_sync if $self->{transport_attached};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"transport_attached"} 0 1 1
483 1 return;
484 }
485  
486 70 ▶sub _handle_priority_update_frame {
Subroutine _handle_priority_update_frame: called CC=5 SCAR=16.6
487 70 my ($self, $frame) = @_;
488 70 ▶ return 0 unless (($frame->{type} // -1) == 0x10);
Branch: 1 branch
BranchTrueFalseTotal
unless ($frame->{"type"} // -1) == 16 69 1 70
Condition50%1/2
$frame->{"type"} // -1
l!l
700
MC/DC0%0/1
$frame->{"type"} // -1
$frame->{"type"}
Truth table50%1/2
A
A= $frame->{"type"}
Aresult
11
00
489  
490 1 ▶ my $stream_id = 0 + ($frame->{prioritized_stream_id} || 0);
Condition50%1/2
$frame->{'prioritized_stream_id'} || 0
l!l
10
MC/DC0%0/1
$frame->{'prioritized_stream_id'} || 0
$frame->{'prioritized_stream_id'}
Truth table50%1/2
A
A= $frame->{'prioritized_stream_id'}
Aresult
11
00
491 my $field_value = defined($frame->{priority_field_value})
492 1 ▶ ? "$frame->{priority_field_value}"
Branch: 1 branch
BranchTrueFalseTotal
defined $frame->{'priority_field_value'} ? : 1 0 1
493 : '';
494  
495 1 $self->_invoke_control_callback(
496 'on_priority',
497 $stream_id,
498 $field_value,
499 );
500 1 return 1;
501 }
502  
503 0 ▶sub local_settings {
Subroutine local_settings: not called CC=2 SCAR=17.9
Pod undocumented
504 0 my ($self) = @_;
505 0 ▶ return { %{ $self->{local_settings} || {} } };
Condition0%0/2
$self->{'local_settings'} || {}
l!l
00
MC/DC0%0/1
$self->{'local_settings'} || {}
$self->{'local_settings'}
Truth table0%0/2
A
A= $self->{'local_settings'}
Aresult
11
00
506 }
507  
508 6 ▶sub local_setting {
Subroutine local_setting: called CC=5 SCAR=19.4
Pod undocumented
509 6 my ($self, $name) = @_;
510 6 ▶ croak 'local_setting(): setting name is required'
Branch: 1 branch
BranchTrueFalseTotal
unless defined $name and not ref $name and length $name 0 6 6
Condition33%2/6
defined $name and not ref $name and length $name
!ll&&!rl&&r
006
defined $name and not ref $name
!ll&&!rl&&r
006
MC/DC0%0/3
defined $name and not ref $name and length $name
defined $name not ref $name length $name
Truth table25%1/4
A and not(B) and C
A= defined $nameB= not ref $nameC= length $name
ABCresult
0XX0
10X0
1100
1111
511 unless defined($name) && !ref($name) && length($name);
512 croak "local_setting(): unknown setting '$name'"
513 6 ▶ unless exists $SETTING_ID{$name};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $SETTING_ID{$name} 0 6 6
514 6 return $self->{local_settings}{$name};
515 }
516  
517 1 ▶sub peer_settings {
Subroutine peer_settings: called CC=4 SCAR=15.6
Pod undocumented
518 1 my ($self) = @_;
519 $self->_refresh_peer_settings
520 1 ▶ if !$self->{closed} && $self->{session};
Branch: 1 branch
BranchTrueFalseTotal
if not $self->{"closed"} and $self->{"session"} 1 0 1
Condition33%1/3
not $self->{"closed"} and $self->{"session"}
!ll&&!rl&&r
001
MC/DC0%0/2
not $self->{"closed"} and $self->{"session"}
not $self->{"closed"} $self->{"session"}
Truth table33%1/3
not(A) and B
A= not $self->{"closed"}B= $self->{"session"}
ABresult
0X0
100
111
521 1 ▶ return { %{ $self->{peer_settings} || {} } };
Condition50%1/2
$self->{'peer_settings'} || {}
l!l
10
MC/DC0%0/1
$self->{'peer_settings'} || {}
$self->{'peer_settings'}
Truth table50%1/2
A
A= $self->{'peer_settings'}
Aresult
11
00
522 }
523  
524 58 ▶sub peer_setting {
Subroutine peer_setting: called CC=7 SCAR=24.4
Pod undocumented
525 58 my ($self, $name) = @_;
526 58 ▶ croak 'peer_setting(): setting name is required'
Branch: 1 branch
BranchTrueFalseTotal
unless defined $name and not ref $name and length $name 0 58 58
Condition33%2/6
defined $name and not ref $name and length $name
!ll&&!rl&&r
0058
defined $name and not ref $name
!ll&&!rl&&r
0058
MC/DC0%0/3
defined $name and not ref $name and length $name
defined $name not ref $name length $name
Truth table25%1/4
A and not(B) and C
A= defined $nameB= not ref $nameC= length $name
ABCresult
0XX0
10X0
1100
1111
527 unless defined($name) && !ref($name) && length($name);
528 croak "peer_setting(): unknown setting '$name'"
529 58 ▶ unless exists $SETTING_ID{$name};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $SETTING_ID{$name} 0 58 58
530  
531 $self->_refresh_peer_settings
532 58 ▶ if !$self->{closed} && $self->{session};
Branch: 1 branch
BranchTrueFalseTotal
if not $self->{"closed"} and $self->{"session"} 58 0 58
Condition33%1/3
not $self->{"closed"} and $self->{"session"}
!ll&&!rl&&r
0058
MC/DC0%0/2
not $self->{"closed"} and $self->{"session"}
not $self->{"closed"} $self->{"session"}
Truth table33%1/3
not(A) and B
A= not $self->{"closed"}B= $self->{"session"}
ABresult
0X0
100
111
533 58 return $self->{peer_settings}{$name};
534 }
535  
536 6 ▶sub settings_pending {
Subroutine settings_pending: called CC=2 SCAR=7.1
Pod undocumented
537 6 my ($self) = @_;
538 6 ▶ return scalar @{ $self->{settings_pending} || [] };
Condition50%1/2
$self->{'settings_pending'} || []
l!l
60
MC/DC0%0/1
$self->{'settings_pending'} || []
$self->{'settings_pending'}
Truth table50%1/2
A
A= $self->{'settings_pending'}
Aresult
11
00
539 }
540  
541 13 ▶sub update_settings {
Subroutine update_settings: called CC=8 SCAR=22.7
Pod undocumented
542 13 my ($self, @settings) = @_;
543  
544 croak 'update_settings(): connection is closed'
545 13 ▶ if $self->{closed} || !$self->{session};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"closed"} or not $self->{"session"} 0 13 13
Condition33%1/3
$self->{"closed"} or not $self->{"session"}
l!l&&r!l&&!r
0013
MC/DC0%0/2
$self->{"closed"} or not $self->{"session"}
$self->{"closed"} not $self->{"session"}
Truth table33%1/3
A or not(B)
A= $self->{"closed"}B= not $self->{"session"}
ABresult
1X1
011
000
546  
547 13 my $input;
548 13 ▶ if (@settings == 1 && ref($settings[0]) eq 'HASH') {
Branch: 2 branches
BranchTrueFalseTotal
if (@settings == 1 and ref $settings[0] eq 'HASH') { } 1 12 13
elsif (@settings and @settings % 2 == 0) { } 12 0 12
Condition66%2/3
@settings == 1 and ref $settings[0] eq "HASH"
!ll&&!rl&&r
1201
MC/DC50%1/2
@settings == 1 and ref $settings[0] eq "HASH"
@settings == 1 ref $settings[0] eq "HASH"
Truth table66%2/3
A and B
A= @settings == 1B= ref $settings[0] eq "HASH"
ABresult
0X0
100
111
549 1 $input = $settings[0];
550 }
551 ▶ elsif (@settings && @settings % 2 == 0) {
Condition33%1/3
@settings and @settings % 2 == 0
!ll&&!rl&&r
0012
MC/DC0%0/2
@settings and @settings % 2 == 0
@settings @settings % 2 == 0
Truth table33%1/3
A and B
A= @settingsB= @settings % 2 == 0
ABresult
0X0
100
111
552 12 $input = { @settings };
553 }
554 else {
555 0 croak 'update_settings(): expected a hash reference or key/value pairs';
556 }
557  
558 13 $self->_submit_settings('update_settings()', $input);
559 5 ▶ $self->_transport_sync if $self->{transport_attached};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"transport_attached"} 1 4 5
560 5 return $self;
561 }
562  
563 95 ▶sub _submit_settings {
Subroutine _submit_settings: called CC=5 SCAR=16.1
564 95 my ($self, $operation, $input) = @_;
565 95 my $settings = $self->_validate_settings($operation, $input);
566  
567 87 $self->{session}->submit_settings($settings);
568  
569 87 my %submitted = %$settings;
570 87 push @{ $self->{settings_pending} }, \%submitted;
571 87 @{$self->{local_settings}}{keys %submitted} = values %submitted;
572  
573 87 ▶ if (exists $submitted{max_header_list_size}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $submitted{"max_header_list_size"}) 82 5 87
574 82 $self->{max_header_list_size} = $submitted{max_header_list_size};
575 }
576 87 ▶ if ($self->{role} eq 'server') {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"role"} eq "server") 39 48 87
577 39 ▶ if (exists $submitted{max_concurrent_streams}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $submitted{"max_concurrent_streams"}) 38 1 39
578 38 $self->{max_concurrent_streams} = $submitted{max_concurrent_streams};
579 }
580 39 ▶ if (exists $submitted{enable_connect_protocol}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $submitted{"enable_connect_protocol"}) 37 2 39
581 $self->{enable_connect_protocol}
582 37 = $submitted{enable_connect_protocol};
583 }
584 }
585  
586 87 return $self;
587 }
588  
589 95 ▶sub _validate_settings {
Subroutine _validate_settings: called CC=30 SCAR=35.4
590 95 my ($self, $operation, $input) = @_;
591  
592 95 ▶ croak "$operation settings must be a hash reference"
Branch: 1 branch
BranchTrueFalseTotal
unless ref $input eq "HASH" 0 95 95
593 unless ref($input) eq 'HASH';
594 95 ▶ croak "$operation requires at least one setting"
Branch: 1 branch
BranchTrueFalseTotal
unless keys %$input 0 95 95
595 unless keys %$input;
596  
597 95 my %settings;
598 95 for my $name (keys %$input) {
599 croak "$operation unknown setting '$name'"
600 346 ▶ unless exists $SETTING_ID{$name};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $SETTING_ID{$name} 1 345 346
601  
602 345 my $value = $input->{$name};
603 345 ▶ croak "$operation $name must be an unsigned integer"
Branch: 1 branch
BranchTrueFalseTotal
unless defined $value and not ref $value and "$value" =~ /\A[0-9]+\z/ 0 345 345
Condition33%2/6
defined $value and not ref $value and "$value" =~ /\A[0-9]+\z/
!ll&&!rl&&r
00345
defined $value and not ref $value
!ll&&!rl&&r
00345
MC/DC0%0/3
defined $value and not ref $value and "$value" =~ /\A[0-9]+\z/
defined $value not ref $value "$value" =~ /\A[0-9]+\z/
Truth table25%1/4
A and not(B) and C
A= defined $valueB= not ref $valueC= "$value" =~ /\A[0-9]+\z/
ABCresult
0XX0
10X0
1100
1111
604 unless defined($value) && !ref($value)
605 && "$value" =~ /\A[0-9]+\z/;
606  
607 345 $value = 0 + $value;
608  
609 345 ▶ if ($name eq 'enable_push'
Branch: 3 branches
BranchTrueFalseTotal
if ($name eq 'enable_push' or $name eq 'enable_connect_protocol' or $name eq 'no_rfc7540_priorities') { } 169 176 345
elsif ($name eq 'initial_window_size') { } 7 169 176
elsif ($name eq 'max_frame_size') { } 1 168 169
Condition100%6/6
$name eq "enable_push" or $name eq "enable_connect_protocol" or $name eq "no_rfc7540_priorities"
l!l&&r!l&&!r
8683176
$name eq "enable_push" or $name eq "enable_connect_protocol"
l!l&&r!l&&!r
4838259
MC/DC100%3/3
$name eq "enable_push" or $name eq "enable_connect_protocol" or $name eq "no_rfc7540_priorities"
$name eq "enable_push" $name eq "enable_connect_protocol" $name eq "no_rfc7540_priorities"
Truth table100%4/4
A or B or C
A= $name eq "enable_push"B= $name eq "enable_connect_protocol"C= $name eq "no_rfc7540_priorities"
ABCresult
1XX1
01X1
0011
0000
610 || $name eq 'enable_connect_protocol'
611 || $name eq 'no_rfc7540_priorities') {
612 169 ▶ croak "$operation $name must be zero or one"
Branch: 1 branch
BranchTrueFalseTotal
unless $value == 0 or $value == 1 0 169 169
Condition66%2/3
$value == 0 or $value == 1
l!l&&r!l&&!r
501190
MC/DC0%0/2
$value == 0 or $value == 1
$value == 0 $value == 1
Truth table66%2/3
A or B
A= $value == 0B= $value == 1
ABresult
1X1
011
000
613 unless $value == 0 || $value == 1;
614 }
615 elsif ($name eq 'initial_window_size') {
616 7 ▶ croak "$operation initial_window_size exceeds HTTP/2 maximum"
Branch: 1 branch
BranchTrueFalseTotal
if $value > 2147483647 1 6 7
617 if $value > 2_147_483_647;
618 }
619 elsif ($name eq 'max_frame_size') {
620 1 ▶ croak "$operation max_frame_size must be between 16384 and 16777215"
Branch: 1 branch
BranchTrueFalseTotal
if $value < 16384 or $value > 16777215 1 0 1
Condition33%1/3
$value < 16384 or $value > 16777215
l!l&&r!l&&!r
100
MC/DC0%0/2
$value < 16384 or $value > 16777215
$value < 16384 $value > 16777215
Truth table33%1/3
A or B
A= $value < 16384B= $value > 16777215
ABresult
1X1
011
000
621 if $value < 16_384 || $value > 16_777_215;
622 }
623 else {
624 168 ▶ croak "$operation $name exceeds HTTP/2 maximum"
Branch: 1 branch
BranchTrueFalseTotal
if $value > 4294967295 0 168 168
625 if $value > 4_294_967_295;
626 }
627  
628 343 $settings{$name} = $value;
629 }
630  
631 92 ▶ if (exists $settings{enable_connect_protocol}
Branch: 1 branch
BranchTrueFalseTotal
if (exists $settings{"enable_connect_protocol"} and ($self->{"local_settings"}{"enable_connect_protocol"} || 0) == 1 and $settings{"enable_connect_protocol"} == 0) 1 91 92
Condition87%7/8
exists $settings{"enable_connect_protocol"} and ($self->{"local_settings"}{"enable_connect_protocol"} || 0) == 1 and $settings{"enable_connect_protocol"} == 0
!ll&&!rl&&r
9101
exists $settings{"enable_connect_protocol"} and ($self->{"local_settings"}{"enable_connect_protocol"} || 0) == 1
!ll&&!rl&&r
54371
$self->{'local_settings'}{'enable_connect_protocol'} || 0
l!l
137
MC/DC66%2/3
exists $settings{"enable_connect_protocol"} and ($self->{"local_settings"}{"enable_connect_protocol"} || 0) == 1 and $settings{"enable_connect_protocol"} == 0
exists $settings{"enable_connect_protocol"} $self->{'local_settings'}{'enable_connect_protocol'} $settings{"enable_connect_protocol"} == 0
Truth table75%3/4
A and B and C
A= exists $settings{"enable_connect_protocol"}B= $self->{'local_settings'}{'enable_connect_protocol'}C= $settings{"enable_connect_protocol"} == 0
ABCresult
0XX0
10X0
1100
1111
632 && ($self->{local_settings}{enable_connect_protocol} || 0) == 1
633 && $settings{enable_connect_protocol} == 0) {
634 1 croak "$operation enable_connect_protocol cannot return to zero after one";
635 }
636  
637 91 ▶ if (exists $settings{no_rfc7540_priorities}
Branch: 1 branch
BranchTrueFalseTotal
if (exists $settings{"no_rfc7540_priorities"} and exists $self->{"local_settings"}{"no_rfc7540_priorities"} and $settings{"no_rfc7540_priorities"} != $self->{"local_settings"}{"no_rfc7540_priorities"}) 1 90 91
Condition83%5/6
exists $settings{"no_rfc7540_priorities"} and exists $self->{"local_settings"}{"no_rfc7540_priorities"} and $settings{"no_rfc7540_priorities"} != $self->{"local_settings"}{"no_rfc7540_priorities"}
!ll&&!rl&&r
9001
exists $settings{"no_rfc7540_priorities"} and exists $self->{"local_settings"}{"no_rfc7540_priorities"}
!ll&&!rl&&r
8821
MC/DC66%2/3
exists $settings{"no_rfc7540_priorities"} and exists $self->{"local_settings"}{"no_rfc7540_priorities"} and $settings{"no_rfc7540_priorities"} != $self->{"local_settings"}{"no_rfc7540_priorities"}
exists $settings{"no_rfc7540_priorities"} exists $self->{"local_settings"}{"no_rfc7540_priorities"} $settings{"no_rfc7540_priorities"} != $self->{"local_settings"}{"no_rfc7540_priorities"}
Truth table75%3/4
A and B and C
A= exists $settings{"no_rfc7540_priorities"}B= exists $self->{"local_settings"}{"no_rfc7540_priorities"}C= $settings{"no_rfc7540_priorities"} != $self->{"local_settings"}{"no_rfc7540_priorities"}
ABCresult
0XX0
10X0
1100
1111
638 && exists $self->{local_settings}{no_rfc7540_priorities}
639 && $settings{no_rfc7540_priorities}
640 != $self->{local_settings}{no_rfc7540_priorities}) {
641 1 croak "$operation no_rfc7540_priorities cannot change after the first SETTINGS frame";
642 }
643  
644 90 ▶ if ($self->{role} eq 'client') {
Branch: 2 branches
BranchTrueFalseTotal
if ($self->{'role'} eq 'client') { } 49 41 90
elsif (exists $settings{'enable_push'}) { } 2 39 41
645 croak "$operation enable_push=1 is unsupported because server push is disabled"
646 49 ▶ if ($settings{enable_push} || 0) == 1;
Branch: 1 branch
BranchTrueFalseTotal
if ($settings{"enable_push"} || 0) == 1 1 48 49
Condition100%2/2
$settings{'enable_push'} || 0
l!l
148
MC/DC100%1/1
$settings{'enable_push'} || 0
$settings{'enable_push'}
Truth table100%2/2
A
A= $settings{'enable_push'}
Aresult
11
00
647 }
648 elsif (exists $settings{enable_push}) {
649 2 croak "$operation a server must not send enable_push";
650 }
651  
652 87 return \%settings;
653 }
654  
655 215 ▶sub _refresh_peer_settings {
Subroutine _refresh_peer_settings: called CC=4 SCAR=13.9
656 215 my ($self) = @_;
657 return $self->{peer_settings}
658 215 ▶ unless $self->{session};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"session"} 0 215 215
659  
660 215 my %settings;
661 215 for my $name (@SETTING_NAMES) {
662 $settings{$name}
663 1720 = 0 + $self->{session}->remote_setting($SETTING_ID{$name});
664 }
665  
666 # ENABLE_PUSH is a client-to-server setting. It has no server-advertised
667 # peer value for a client, and Unblock does not support server push.
668 215 ▶ $settings{enable_push} = 0 if $self->{role} eq 'client';
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"role"} eq "client" 137 78 215
669  
670 215 $self->{peer_settings} = \%settings;
671 215 return $self->{peer_settings};
672 }
673  
674 297 ▶sub _handle_settings_frame {
Subroutine _handle_settings_frame: called CC=11 SCAR=24.6
675 297 my ($self, $frame) = @_;
676 297 ▶ return 0 unless (($frame->{type} // -1) == 4);
Branch: 1 branch
BranchTrueFalseTotal
unless ($frame->{"type"} // -1) == 4 158 139 297
Condition50%1/2
$frame->{"type"} // -1
l!l
2970
MC/DC0%0/1
$frame->{"type"} // -1
$frame->{"type"}
Truth table50%1/2
A
A= $frame->{"type"}
Aresult
11
00
677  
678 139 ▶ if (($frame->{flags} || 0) & 0x1) {
Branch: 1 branch
BranchTrueFalseTotal
if (($frame->{"flags"} || 0) & 1) 65 74 139
Condition100%2/2
$frame->{'flags'} || 0
l!l
6574
MC/DC100%1/1
$frame->{'flags'} || 0
$frame->{'flags'}
Truth table100%2/2
A
A= $frame->{'flags'}
Aresult
11
00
679 65 my $acked = shift @{ $self->{settings_pending} };
680 65 ▶ $acked ||= {};
Condition50%1/2
$acked ||= {}
l!l
650
MC/DC0%0/1
$acked ||= {}
$acked
Truth table50%1/2
A
A= $acked
Aresult
11
00
681 65 $self->_invoke_control_callback(
682 'on_settings_ack',
683 { %$acked },
684 );
685 65 return 1;
686 }
687  
688 74 my %changed;
689 74 ▶ for my $pair (@{ $frame->{settings} || [] }) {
Condition50%1/2
$frame->{'settings'} || []
l!l
740
MC/DC0%0/1
$frame->{'settings'} || []
$frame->{'settings'}
Truth table50%1/2
A
A= $frame->{'settings'}
Aresult
11
00
690 289 ▶ next unless ref($pair) eq 'ARRAY' && @$pair >= 2;
Branch: 1 branch
BranchTrueFalseTotal
unless ref $pair eq "ARRAY" and @$pair >= 2 0 289 289
Condition33%1/3
ref $pair eq "ARRAY" and @$pair >= 2
!ll&&!rl&&r
00289
MC/DC0%0/2
ref $pair eq "ARRAY" and @$pair >= 2
ref $pair eq "ARRAY" @$pair >= 2
Truth table33%1/3
A and B
A= ref $pair eq "ARRAY"B= @$pair >= 2
ABresult
0X0
100
111
691 289 my ($id, $value) = @$pair;
692 289 my $name = $SETTING_NAME{$id};
693 289 ▶ next unless defined $name;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $name 0 289 289
694 289 $changed{$name} = 0 + $value;
695 }
696  
697 74 my $peer = $self->_refresh_peer_settings;
698 74 $self->_invoke_control_callback(
699 'on_settings',
700 { %$peer },
701 \%changed,
702 );
703  
704 74 return 1;
705 }
706  
707 149 ▶sub _invoke_control_callback {
Subroutine _invoke_control_callback: called CC=5 SCAR=16.3
708 149 my ($self, $name, @args) = @_;
709 149 ▶ my $callback = $self->{callbacks}{$name} or return 1;
Branch: 1 branch
BranchTrueFalseTotal
my $callback = $self->{"callbacks"}{$name} or return 1 18 131 149
710  
711 18 my $ok = eval {
712 18 $callback->($self, @args);
713 16 1;
714 };
715  
716 18 ▶ return 1 if $ok;
Branch: 1 branch
BranchTrueFalseTotal
if $ok 16 2 18
717  
718 2 my $error = "$name callback failed";
719 2 ▶ $error .= ": $@" if length $@;
Branch: 1 branch
BranchTrueFalseTotal
if length $@ 2 0 2
720 # An application control callback exception is fatal, not an explicit
721 # graceful close. Defer teardown until libnghttp2 has returned when the
722 # callback runs from inside a native receive/send call.
723 2 ▶ if ($self->{in_session_call}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'in_session_call'}) { } 2 0 2
724 2 $self->{close_pending} = $error;
725 }
726 else {
727 0 $self->_finish_close($error);
728 }
729 2 return 0;
730 }
731  
732 371 ▶sub _after_session_call {
Subroutine _after_session_call: called CC=8 SCAR=26.6
733 371 my ($self) = @_;
734  
735 371 my @ids = keys %{ $self->{pending_drain} };
736 371 $self->{pending_drain} = {};
737  
738 371 for my $stream_id (@ids) {
739 3 ▶ my $transaction = $self->{transactions}{$stream_id} or next;
Branch: 1 branch
BranchTrueFalseTotal
my $transaction = $self->{"transactions"}{$stream_id} or next 3 0 3
740 3 ▶ next if $transaction->is_terminal;
Branch: 1 branch
BranchTrueFalseTotal
if $transaction->is_terminal 0 3 3
741  
742 3 my $result = $transaction->_drain;
743 3 ▶ next if $result && $result eq '1';
Branch: 1 branch
BranchTrueFalseTotal
if $result and $result eq 1 3 0 3
Condition33%1/3
$result and $result eq 1
!ll&&!rl&&r
003
MC/DC0%0/2
$result and $result eq 1
$result $result eq 1
Truth table33%1/3
A and B
A= $resultB= $result eq 1
ABresult
0X0
100
111
744  
745 0 ▶ if ($result && $result ne '1') {
Branch: 1 branch
BranchTrueFalseTotal
if ($result and $result ne 1) 0 0 0
Condition0%0/3
$result and $result ne 1
!ll&&!rl&&r
000
MC/DC0%0/2
$result and $result ne 1
$result $result ne 1
Truth table0%0/3
A and B
A= $resultB= $result ne 1
ABresult
0X0
100
111
746 0 $self->_stream_failure($stream_id, "$result");
747 }
748 }
749  
750 371 return;
751 }
752  
753 38 ▶sub _body_bytes {
Subroutine _body_bytes: called CC=5 SCAR=17.8
754 38 my ($self, $operation, $bytes) = @_;
755  
756 38 ▶ croak "$operation: body must be a scalar" if ref($bytes);
Branch: 1 branch
BranchTrueFalseTotal
if ref $bytes 3 35 38
757 35 ▶ $bytes = '' unless defined $bytes;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $bytes 0 35 35
758  
759 35 my $copy = "$bytes";
760 35 ▶ if (utf8::is_utf8($copy)) {
Branch: 1 branch
BranchTrueFalseTotal
if (utf8::is_utf8($copy)) 0 35 35
761 0 ▶ croak "$operation: body must be a byte string"
Branch: 1 branch
BranchTrueFalseTotal
unless utf8::downgrade($copy, 1) 0 0 0
762 unless utf8::downgrade($copy, 1);
763 }
764  
765 35 return $copy;
766 }
767  
768 9 ▶sub close {
Subroutine close: called CC=6 SCAR=17.9
Pod undocumented
769 9 my ($self, $error) = @_;
770 9 ▶ return $self if $self->{closed};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"closed"} 1 8 9
771  
772 8 ▶ $error = 'HTTP/2 connection closed'
Branch: 1 branch
BranchTrueFalseTotal
unless defined $error and length $error 4 4 8
Condition66%2/3
defined $error and length $error
!ll&&!rl&&r
404
MC/DC50%1/2
defined $error and length $error
defined $error length $error
Truth table66%2/3
A and B
A= defined $errorB= length $error
ABresult
0X0
100
111
773 unless defined($error) && length($error);
774  
775 8 ▶ $self->{transport_graceful} = 1 if $self->{transport_attached};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"transport_attached"} 4 4 8
776 8 ▶ if ($self->{in_session_call}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"in_session_call"}) 2 6 8
777 2 $self->{close_pending} = "$error";
778 2 return $self;
779 }
780  
781 6 return $self->_finish_close($error);
782 }
783  
784 16 ▶sub _finish_close {
Subroutine _finish_close: called CC=10 SCAR=23.1
785 16 my ($self, $error) = @_;
786 16 ▶ return $self if $self->{closed};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"closed"} 0 16 16
787  
788 16 ▶ if ($self->{transport_graceful} && !$self->{transport_aborted}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"transport_graceful"} and not $self->{"transport_aborted"}) 4 12 16
Condition66%2/3
$self->{"transport_graceful"} and not $self->{"transport_aborted"}
!ll&&!rl&&r
1204
MC/DC50%1/2
$self->{"transport_graceful"} and not $self->{"transport_aborted"}
$self->{"transport_graceful"} not $self->{"transport_aborted"}
Truth table66%2/3
A and not(B)
A= $self->{"transport_graceful"}B= not $self->{"transport_aborted"}
ABresult
0X0
100
111
789 4 my $ok = eval { $self->_stage_final_output; 1 };
790 4 ▶ $self->{transport_graceful} = 0 unless $ok;
Branch: 1 branch
BranchTrueFalseTotal
unless $ok 0 4 4
791 }
792 16 $self->{closed} = 1;
793 16 $self->{close_reason} = "$error";
794  
795 16 for my $transaction (values %{ $self->{transactions} }) {
796 4 ▶ next if $transaction->is_terminal;
Branch: 1 branch
BranchTrueFalseTotal
if $transaction->is_terminal 0 4 4
797 4 $transaction->_fail($error);
798 4 $self->_invoke_stream_error($transaction, $error);
799 }
800  
801 16 $self->{transactions} = {};
802 16 $self->{pending_drain} = {};
803 16 $self->{session} = undef;
804 16 ▶ if ($self->{transport_attached}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"transport_attached"}) 9 7 16
805 9 ▶ if ($self->{transport_graceful}) {
Branch: 2 branches
BranchTrueFalseTotal
if ($self->{'transport_graceful'}) { } 4 5 9
elsif (not $self->{'transport_aborted'}) { } 1 4 5
806 4 $self->_transport_sync;
807 }
808 elsif (!$self->{transport_aborted}) {
809 1 $self->_transport_abort($error);
810 }
811 }
812 16 return $self;
813 }
814  
815 7 ▶sub _invoke_stream_error {
Subroutine _invoke_stream_error: called CC=1 SCAR=0.0
816 7 my ($self, $transaction, $error, $error_code) = @_;
817 7 my $result = $transaction->_invoke('on_error', $error, $error_code);
818 7 return $result;
819 }
820  
821 28 1;
« blib/lib/Unblock/HTTP2/_nghttp2.pm ↑ Summary blib/lib/Unblock/HTTP2/Transaction.pm »