blib/lib/Unblock/HTTP2/_Connection.pm

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