HTTP2/Stream.pm

filter: Statementstmt 78.2% 169 / 216 Branchbran 71.1% 84 / 118 Conditioncond 57.1% 24 / 42 MC/DCmcdc 32.0% 8 / 25 Subroutinesub 96.0% 24 / 25 Podpod 0.0% 0 / 17 totaltotal 69.7% 309 / 443 CC 82 SCAR 31.0
CC
82
Cov
74%
validate_headers
87.0
stream_state
14.3
stream_reprio
14.2
CRAP 22.1
« HTTP2/Frame/Push_promise.pm ↑ Summary HTTP2/Frame/Data.pm »
1 package Protocol::HTTP2::Stream;
2 13 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 13 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 13 ▶use Protocol::HTTP2::Constants qw(:states :endpoints :settings :frame_types
Subroutine BEGIN: called CC=1 SCAR=0.0
5 13 :limits :errors);
6 13 ▶use Protocol::HTTP2::HeaderCompression qw( headers_decode );
Subroutine BEGIN: called CC=1 SCAR=0.0
7 13 ▶use Protocol::HTTP2::Trace qw(tracer);
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 # Streams related part of Protocol::HTTP2::Conntection
10  
11 # Autogen properties
12 {
13 13 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
14 13 for my $prop (
15 qw(promised_sid headers pp_headers header_block trailer
16 trailer_headers length blocked_data weight end reset)
17 )
18 {
19 143 ▶ *{ __PACKAGE__ . '::stream_' . $prop } = sub {
Subroutine __ANON__: called CC=3 SCAR=11.1
20 return
21 !exists $_[0]->{streams}->{ $_[1] } ? undef
22 : @_ == 2 ? $_[0]->{streams}->{ $_[1] }->{$prop}
23 737 ▶ : ( $_[0]->{streams}->{ $_[1] }->{$prop} = $_[2] );
Branch: 2 branches
BranchTrueFalseTotal
!exists($_[0]{'streams'}{$_[1]}) ? : 0 737 737
@_ == 2 ? : 572 165 737
24 }
25 143 }
26 }
27  
28 45 ▶sub new_stream {
Subroutine new_stream: called CC=4 SCAR=13.9
Pod undocumented
29 45 my $self = shift;
30 45 ▶ return undef if $self->goaway;
Branch: 1 branch
BranchTrueFalseTotal
if $self->goaway 2 43 45
31  
32 $self->{last_stream} += 2
33 43 ▶ if exists $self->{streams}->{ $self->{type} == CLIENT ? 1 : 2 };
Branch: 2 branches
BranchTrueFalseTotal
if exists $self->{"streams"}{$self->{"type"} == 1 ? 1 : 2} 21 22 43
$self->{'type'} == 1 ? : 43 0 43
34 $self->{streams}->{ $self->{last_stream} } = {
35 43 'state' => IDLE,
36 'weight' => DEFAULT_WEIGHT,
37 'stream_dep' => 0,
38 'fcw_recv' => $self->dec_setting(SETTINGS_INITIAL_WINDOW_SIZE),
39 'fcw_send' => $self->enc_setting(SETTINGS_INITIAL_WINDOW_SIZE),
40 };
41 43 return $self->{last_stream};
42 }
43  
44 44 ▶sub new_peer_stream {
Subroutine new_peer_stream: called CC=6 SCAR=21.3
Pod undocumented
45 44 my $self = shift;
46 44 my $stream_id = shift;
47 44 ▶ if ( $stream_id < $self->{last_peer_stream}
Branch: 2 branches
BranchTrueFalseTotal
if ($stream_id < $self->{"last_peer_stream"} || $stream_id % 2 == ($self->{"type"} == 1) ? 1 : $self->goaway) 0 44 44
$stream_id < $self->{'last_peer_stream'} || $stream_id % 2 == ($self->{'type'} == 1) ? : 0 44 44
Condition33%1/3
$stream_id < $self->{"last_peer_stream"} or $stream_id % 2 == ($self->{"type"} == 1)
l!l&&r!l&&!r
0044
MC/DC0%0/2
$stream_id < $self->{"last_peer_stream"} or $stream_id % 2 == ($self->{"type"} == 1)
$stream_id < $self->{"last_peer_stream"} $stream_id % 2 == ($self->{"type"} == 1)
Truth table33%1/3
A or B
A= $stream_id < $self->{"last_peer_stream"}B= $stream_id % 2 == ($self->{"type"} == 1)
ABresult
1X1
011
000
48 || ( $stream_id % 2 ) == ( $self->{type} == CLIENT ) ? 1 : 0
49 || $self->goaway )
50 {
51 0 tracer->error("Peer send invalid stream id: $stream_id\n");
52 0 $self->error(PROTOCOL_ERROR);
53 0 return undef;
54 }
55 44 $self->{last_peer_stream} = $stream_id;
56 44 ▶ if ( $self->dec_setting(SETTINGS_MAX_CONCURRENT_STREAMS) <=
Branch: 1 branch
BranchTrueFalseTotal
if ($self->dec_setting(3) <= $self->{"active_peer_streams"}) 0 44 44
57 $self->{active_peer_streams} )
58 {
59 0 tracer->warning("SETTINGS_MAX_CONCURRENT_STREAMS exceeded\n");
60 0 $self->stream_error( $stream_id, REFUSED_STREAM );
61 0 return undef;
62 }
63 44 $self->{active_peer_streams}++;
64 44 tracer->debug("Active streams: $self->{active_peer_streams}");
65 44 $self->{streams}->{$stream_id} = {
66 'state' => IDLE,
67 'weight' => DEFAULT_WEIGHT,
68 'stream_dep' => 0,
69 'fcw_recv' => $self->dec_setting(SETTINGS_INITIAL_WINDOW_SIZE),
70 'fcw_send' => $self->enc_setting(SETTINGS_INITIAL_WINDOW_SIZE),
71 };
72 $self->{on_new_peer_stream}->($stream_id)
73 44 ▶ if exists $self->{on_new_peer_stream};
Branch: 1 branch
BranchTrueFalseTotal
if exists $self->{"on_new_peer_stream"} 36 8 44
74  
75 44 return $self->{last_peer_stream};
76 }
77  
78 141 ▶sub stream {
Subroutine stream: called CC=2 SCAR=6.9
Pod undocumented
79 141 my ( $self, $stream_id ) = @_;
80 141 ▶ return undef unless exists $self->{streams}->{$stream_id};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $self->{"streams"}{$stream_id} 37 104 141
81  
82 104 $self->{streams}->{$stream_id};
83 }
84  
85 # stream_state ( $self, $stream_id, $new_state?, $pending? )
86  
87 158 ▶sub stream_state {
Subroutine stream_state: called CC=14 SCAR=26.6
Pod undocumented
88 158 my $self = shift;
89 158 my $stream_id = shift;
90 158 ▶ return undef unless exists $self->{streams}->{$stream_id};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $self->{"streams"}{$stream_id} 0 158 158
91 158 my $s = $self->{streams}->{$stream_id};
92  
93 158 ▶ if (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 158 0 158
94 158 my ( $new_state, $pending ) = @_;
95  
96 158 ▶ if ($pending) {
Branch: 1 branch
BranchTrueFalseTotal
if ($pending) { } 3 155 158
97 3 $self->stream_pending_state( $stream_id, $new_state );
98 }
99 else {
100 $self->{on_change_state}->( $stream_id, $s->{state}, $new_state )
101 155 ▶ if exists $self->{on_change_state};
Branch: 1 branch
BranchTrueFalseTotal
if exists $self->{"on_change_state"} 0 155 155
102  
103 155 $s->{state} = $new_state;
104  
105 # Exec callbacks for new state
106 155 ▶ if ( exists $s->{cb} && exists $s->{cb}->{ $s->{state} } ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $s->{"cb"} and exists $s->{"cb"}{$s->{"state"}}) 72 83 155
Condition100%3/3
exists $s->{"cb"} and exists $s->{"cb"}{$s->{"state"}}
!ll&&!rl&&r
513272
MC/DC100%2/2
exists $s->{"cb"} and exists $s->{"cb"}{$s->{"state"}}
exists $s->{"cb"} exists $s->{"cb"}{$s->{"state"}}
Truth table100%3/3
A and B
A= exists $s->{"cb"}B= exists $s->{"cb"}{$s->{"state"}}
ABresult
0X0
100
111
107 72 for my $cb ( @{ $s->{cb}->{ $s->{state} } } ) {
108 72 $cb->();
109 }
110 }
111  
112 # Cleanup
113 155 ▶ if ( $new_state == CLOSED ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($new_state == 5) 71 84 155
114 $self->{active_peer_streams}--
115 if $self->{active_peer_streams}
116 71 ▶ && ( ( $stream_id % 2 ) ^ ( $self->{type} == CLIENT ) );
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"active_peer_streams"} and $stream_id % 2 ^ $self->{"type"} == 1 34 37 71
Condition66%2/3
$self->{"active_peer_streams"} and $stream_id % 2 ^ $self->{"type"} == 1
!ll&&!rl&&r
37034
MC/DC50%1/2
$self->{"active_peer_streams"} and $stream_id % 2 ^ $self->{"type"} == 1
$self->{"active_peer_streams"} $stream_id % 2 ^ $self->{"type"} == 1
Truth table66%2/3
A and B
A= $self->{"active_peer_streams"}B= $stream_id % 2 ^ $self->{"type"} == 1
ABresult
0X0
100
111
117 71 tracer->info(
118 "Active streams: $self->{active_peer_streams} $stream_id");
119 71 for my $key ( keys %$s ) {
120 632 ▶ next if grep { $key eq $_ } (
Branch: 1 branch
BranchTrueFalseTotal
if grep {$key eq $_;} "state", "weight", "stream_dep", "fcw_recv", "fcw_send", "reset" 365 267 632
121 qw(state weight stream_dep
122 fcw_recv fcw_send reset)
123 );
124 267 delete $s->{$key};
125 }
126  
127 # Prevent endless growth of closed streams structure
128 # Drop old closed streams (possible violation of the standard)
129 71 push @{ $self->{closed_streams} }, $stream_id;
130 0 delete $self->{streams}->{ shift @{ $self->{closed_streams} } }
131 71 if @{ $self->{closed_streams} } > $self->{max_closed_streams}
132 71 ▶ }
Branch: 1 branch
BranchTrueFalseTotal
if @{$self->{"closed_streams"};} > $self->{"max_closed_streams"} 0 71 71
133 }
134 }
135  
136 158 $s->{state};
137 }
138  
139 266 ▶sub stream_pending_state {
Subroutine stream_pending_state: called CC=4 SCAR=13.9
Pod undocumented
140 266 my $self = shift;
141 266 my $stream_id = shift;
142 266 ▶ return undef unless exists $self->{streams}->{$stream_id};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $self->{"streams"}{$stream_id} 0 266 266
143 266 my $s = $self->{streams}->{$stream_id};
144 266 ▶ if (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 6 260 266
145 6 $s->{pending_state} = shift;
146 $self->{pending_stream} =
147 6 ▶ defined $s->{pending_state} ? $stream_id : undef;
Branch: 1 branch
BranchTrueFalseTotal
defined $s->{'pending_state'} ? : 3 3 6
148 }
149 266 $s->{pending_state};
150 }
151  
152 74 ▶sub stream_cb {
Subroutine stream_cb: called CC=2 SCAR=7.0
Pod undocumented
153 74 my ( $self, $stream_id, $state, $cb ) = @_;
154  
155 74 ▶ return undef unless exists $self->{streams}->{$stream_id};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $self->{"streams"}{$stream_id} 0 74 74
156  
157 74 push @{ $self->{streams}->{$stream_id}->{cb}->{$state} }, $cb;
158 }
159  
160 10 ▶sub stream_frame_cb {
Subroutine stream_frame_cb: called CC=2 SCAR=7.0
Pod undocumented
161 10 my ( $self, $stream_id, $frame, $cb ) = @_;
162  
163 10 ▶ return undef unless exists $self->{streams}->{$stream_id};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $self->{"streams"}{$stream_id} 0 10 10
164  
165 10 push @{ $self->{streams}->{$stream_id}->{frame_cb}->{$frame} }, $cb;
166 }
167  
168 93 ▶sub stream_data {
Subroutine stream_data: called CC=6 SCAR=18.0
Pod undocumented
169 93 my $self = shift;
170 93 my $stream_id = shift;
171 93 ▶ return undef unless exists $self->{streams}->{$stream_id};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $self->{"streams"}{$stream_id} 0 93 93
172 93 my $s = $self->{streams}->{$stream_id};
173  
174 93 ▶ if (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 20 73 93
175  
176 # Exec callbacks for data
177 20 ▶ if ( exists $s->{frame_cb} && exists $s->{frame_cb}->{&DATA} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $s->{'frame_cb'} and exists $s->{'frame_cb'}{&DATA}) { } 5 15 20
Condition66%2/3
exists $s->{"frame_cb"} and exists $s->{"frame_cb"}{&DATA}
!ll&&!rl&&r
1505
MC/DC50%1/2
exists $s->{"frame_cb"} and exists $s->{"frame_cb"}{&DATA}
exists $s->{"frame_cb"} exists $s->{"frame_cb"}{&DATA}
Truth table66%2/3
A and B
A= exists $s->{"frame_cb"}B= exists $s->{"frame_cb"}{&DATA}
ABresult
0X0
100
111
178 5 for my $cb ( @{ $s->{frame_cb}->{&DATA} } ) {
179 5 $cb->( $_[0] );
180 }
181 }
182 else {
183 15 $s->{data} .= shift;
184 }
185 }
186  
187 93 $s->{data};
188 }
189  
190 76 ▶sub stream_headers_done {
Subroutine stream_headers_done: called CC=10 SCAR=23.8
Pod undocumented
191 76 my $self = shift;
192 76 my $stream_id = shift;
193 76 ▶ return undef unless exists $self->{streams}->{$stream_id};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $self->{"streams"}{$stream_id} 0 76 76
194 76 my $s = $self->{streams}->{$stream_id};
195  
196 my $res =
197 headers_decode( $self, \$s->{header_block}, 0,
198 76 length $s->{header_block}, $stream_id );
199  
200 76 tracer->debug("Headers done for stream $stream_id\n");
201  
202 76 ▶ return undef unless defined $res;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $res 2 74 76
203  
204 # Clear header_block
205 74 $s->{header_block} = '';
206  
207 74 my $eh = $self->decode_context->{emitted_headers};
208 74 ▶ my $is_response = $self->{type} == CLIENT && !$s->{promised_sid};
Condition66%2/3
$self->{'type'} == 1 && !$s->{'promised_sid'}
!ll&&!rl&&r
37037
MC/DC50%1/2
$self->{'type'} == 1 && !$s->{'promised_sid'}
$self->{'type'} == 1 !$s->{'promised_sid'}
Truth table66%2/3
A && not(B)
A= $self->{'type'} == 1B= !$s->{'promised_sid'}
ABresult
0X0
100
111
209 74 my $is_trailer = !!$self->stream_trailer($stream_id);
210  
211 return undef
212 74 ▶ unless $self->validate_headers( $eh, $stream_id, $is_response );
Branch: 1 branch
BranchTrueFalseTotal
unless $self->validate_headers($eh, $stream_id, $is_response) 0 74 74
213  
214 74 ▶ if ( $s->{promised_sid} ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($s->{'promised_sid'}) { } 0 74 74
elsif ($is_trailer) { } 0 74 74
215 0 $self->{streams}->{ $s->{promised_sid} }->{pp_headers} = $eh;
216 }
217 elsif ($is_trailer) {
218 0 $self->stream_trailer_headers( $stream_id, $eh );
219 }
220 else {
221 74 $s->{headers} = $eh;
222 }
223  
224 # Exec callbacks for headers
225 74 ▶ if ( exists $s->{frame_cb} && exists $s->{frame_cb}->{&HEADERS} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $s->{"frame_cb"} and exists $s->{"frame_cb"}{&HEADERS}) 5 69 74
Condition66%2/3
exists $s->{"frame_cb"} and exists $s->{"frame_cb"}{&HEADERS}
!ll&&!rl&&r
6905
MC/DC50%1/2
exists $s->{"frame_cb"} and exists $s->{"frame_cb"}{&HEADERS}
exists $s->{"frame_cb"} exists $s->{"frame_cb"}{&HEADERS}
Truth table66%2/3
A and B
A= exists $s->{"frame_cb"}B= exists $s->{"frame_cb"}{&HEADERS}
ABresult
0X0
100
111
226 5 for my $cb ( @{ $s->{frame_cb}->{&HEADERS} } ) {
227 5 $cb->($eh);
228 }
229 }
230  
231 # Clear emitted headers
232 74 $self->decode_context->{emitted_headers} = [];
233  
234 74 return 1;
235 }
236  
237 74 ▶sub validate_headers {
Subroutine validate_headers: called CC=19 SCAR=44.7
Pod undocumented
238 74 my ( $self, $headers, $stream_id, $is_response ) = @_;
239 74 my $pseudo_flag = 1;
240 74 my %pseudo_hash = ();
241 74 ▶ my @h = $is_response ? (qw(:status)) : (
Branch: 1 branch
BranchTrueFalseTotal
$is_response ? : 37 37 74
242 qw(:method :scheme :authority
243 :path)
244 );
245  
246 # Trailer headers ?
247 74 ▶ if ( my $t = $self->stream_trailer($stream_id) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $t = $self->stream_trailer($stream_id)) 0 74 74
248 0 for my $i ( 0 .. @$headers / 2 - 1 ) {
249 0 my ( $h, $v ) = ( $headers->[ $i * 2 ], $headers->[ $i * 2 + 1 ] );
250 0 ▶ if ( !exists $t->{$h} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (exists $t->{$h}) 0 0 0
251 0 tracer->warning(
252 "header <$h> doesn't listed in the trailer header");
253 0 $self->stream_error( $stream_id, PROTOCOL_ERROR );
254 0 return undef;
255 }
256 }
257 0 return 1;
258 }
259  
260 74 for my $i ( 0 .. @$headers / 2 - 1 ) {
261 2245 my ( $h, $v ) = ( $headers->[ $i * 2 ], $headers->[ $i * 2 + 1 ] );
262 2245 ▶ if ( $h =~ /^\:/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($h =~ /^\:/) 185 2060 2245
263 185 ▶ if ( !$pseudo_flag ) {
Branch: 3 branches
BranchTrueFalseTotal
if (not $pseudo_flag) { } 0 185 185
elsif (not grep({$_ eq $h;} @h)) { } 0 185 185
elsif (exists $pseudo_hash{$h}) { } 0 185 185
264 0 tracer->warning(
265 "pseudo-header <$h> appears after a regular header");
266 0 $self->stream_error( $stream_id, PROTOCOL_ERROR );
267 0 return undef;
268 }
269 629 elsif ( !grep { $_ eq $h } @h ) {
270 0 tracer->warning("invalid pseudo-header <$h>");
271 0 $self->stream_error( $stream_id, PROTOCOL_ERROR );
272 0 return undef;
273 }
274 elsif ( exists $pseudo_hash{$h} ) {
275 0 tracer->warning("repeated pseudo-header <$h>");
276 0 $self->stream_error( $stream_id, PROTOCOL_ERROR );
277 0 return undef;
278 }
279  
280 185 $pseudo_hash{$h} = $v;
281 185 next;
282 }
283  
284 2060 ▶ $pseudo_flag = 0 if $pseudo_flag;
Branch: 1 branch
BranchTrueFalseTotal
if $pseudo_flag 27 2033 2060
285  
286 2060 ▶ if ( $h eq 'connection' ) {
Branch: 4 branches
BranchTrueFalseTotal
if ($h eq 'connection') { } 0 2060 2060
elsif ($h eq 'te' and $v ne 'trailers') { } 0 2060 2060
elsif ($h eq 'content-length') { } 3 2057 2060
elsif ($h eq 'trailer') { } 0 2057 2057
287 0 tracer->warning("connection header is not valid in http/2");
288 0 $self->stream_error( $stream_id, PROTOCOL_ERROR );
289 0 return undef;
290 }
291 ▶ elsif ( $h eq 'te' && $v ne 'trailers' ) {
Condition33%1/3
$h eq "te" and $v ne "trailers"
!ll&&!rl&&r
206000
MC/DC0%0/2
$h eq "te" and $v ne "trailers"
$h eq "te" $v ne "trailers"
Truth table33%1/3
A and B
A= $h eq "te"B= $v ne "trailers"
ABresult
0X0
100
111
292 0 tracer->warning("TE header can contain only value 'trailers'");
293 0 $self->stream_error( $stream_id, PROTOCOL_ERROR );
294 0 return undef;
295 }
296 elsif ( $h eq 'content-length' ) {
297 3 $self->stream_length( $stream_id, $v );
298 }
299 elsif ( $h eq 'trailer' ) {
300 0 my %th = map { $_ => 1 } split /\s*,\s*/, lc($v);
301 0 ▶ if (
Branch: 1 branch
BranchTrueFalseTotal
if (grep {exists $th{$_};} "transfer-encoding", "content-length", "host", "authentication", "cache-control", "expect", "max-forwards", "pragma", "range", "te", "content-encoding", "content-type", "content-range", "trailer") 0 0 0
302 0 grep { exists $th{$_} } (
303 qw(transfer-encoding content-length host authentication
304 cache-control expect max-forwards pragma range te
305 content-encoding content-type content-range trailer)
306 )
307 )
308 {
309 0 tracer->warning("trailer header contain forbidden headers");
310 0 $self->stream_error( $stream_id, PROTOCOL_ERROR );
311 0 return undef;
312 }
313 0 $self->stream_trailer( $stream_id, {%th} );
314 }
315 }
316  
317 74 for my $h (@h) {
318 185 ▶ next if exists $pseudo_hash{$h};
Branch: 1 branch
BranchTrueFalseTotal
if exists $pseudo_hash{$h} 185 0 185
319  
320 0 tracer->warning("missed mandatory pseudo-header $h");
321 0 $self->stream_error( $stream_id, PROTOCOL_ERROR );
322 0 return undef;
323 }
324  
325 74 1;
326 }
327  
328 # RST_STREAM for stream errors
329 5 ▶sub stream_error {
Subroutine stream_error: called CC=1 SCAR=0.0
Pod undocumented
330 5 my ( $self, $stream_id, $error ) = @_;
331 5 $self->enqueue( RST_STREAM, 0, $stream_id, $error );
332 }
333  
334 # Flow control windown of stream
335 143 ▶sub _stream_fcw {
Subroutine _stream_fcw: called CC=3 SCAR=11.0
336 143 my $dir = shift;
337 143 my $self = shift;
338 143 my $stream_id = shift;
339 143 ▶ return undef unless exists $self->{streams}->{$stream_id};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $self->{"streams"}{$stream_id} 0 143 143
340 143 my $s = $self->{streams}->{$stream_id};
341  
342 143 ▶ if (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 95 48 143
343 95 $s->{$dir} += shift;
344 95 tracer->debug( "Stream $stream_id $dir now is " . $s->{$dir} . "\n" );
345 }
346 143 $s->{$dir};
347 }
348  
349 94 ▶sub stream_fcw_send {
Subroutine stream_fcw_send: called CC=1 SCAR=0.0
Pod undocumented
350 94 _stream_fcw( 'fcw_send', @_ );
351 }
352  
353 49 ▶sub stream_fcw_recv {
Subroutine stream_fcw_recv: called CC=1 SCAR=0.0
Pod undocumented
354 49 _stream_fcw( 'fcw_recv', @_ );
355 }
356  
357 0 ▶sub stream_fcw_update {
Subroutine stream_fcw_update: not called CC=1 SCAR=6.9
Pod undocumented
358 0 my ( $self, $stream_id ) = @_;
359  
360 # TODO: check size of data of stream in memory
361 0 my $size = $self->dec_setting(SETTINGS_INITIAL_WINDOW_SIZE);
362 0 tracer->debug("update fcw recv of stream $stream_id with $size b.\n");
363 0 $self->stream_fcw_recv( $stream_id, $size );
364 0 $self->enqueue( WINDOW_UPDATE, 0, $stream_id, $size );
365 }
366  
367 3 ▶sub stream_send_blocked {
Subroutine stream_send_blocked: called CC=5 SCAR=16.6
Pod undocumented
368 3 my ( $self, $stream_id ) = @_;
369 3 ▶ my $s = $self->{streams}->{$stream_id} or return undef;
Branch: 1 branch
BranchTrueFalseTotal
my $s = $self->{"streams"}{$stream_id} or return undef 3 0 3
370  
371 3 ▶ if ( defined( $s->{blocked_data} ) && length( $s->{blocked_data} )
Branch: 1 branch
BranchTrueFalseTotal
if (defined $s->{"blocked_data"} and length $s->{"blocked_data"} and $self->stream_fcw_send($stream_id) > 0) 1 2 3
Condition66%4/6
defined $s->{"blocked_data"} and length $s->{"blocked_data"} and $self->stream_fcw_send($stream_id) > 0
!ll&&!rl&&r
201
defined $s->{"blocked_data"} and length $s->{"blocked_data"}
!ll&&!rl&&r
201
MC/DC33%1/3
defined $s->{"blocked_data"} and length $s->{"blocked_data"} and $self->stream_fcw_send($stream_id) > 0
defined $s->{"blocked_data"} length $s->{"blocked_data"} $self->stream_fcw_send($stream_id) > 0
Truth table50%2/4
A and B and C
A= defined $s->{"blocked_data"}B= length $s->{"blocked_data"}C= $self->stream_fcw_send($stream_id) > 0
ABCresult
0XX0
10X0
1100
1111
372 && $self->stream_fcw_send($stream_id) > 0 )
373 {
374 1 $self->send_data($stream_id);
375 }
376 }
377  
378 7 ▶sub stream_reprio {
Subroutine stream_reprio: called CC=13 SCAR=26.5
Pod undocumented
379 7 my ( $self, $stream_id, $exclusive, $stream_dep ) = @_;
380 return undef
381 unless exists $self->{streams}->{$stream_id}
382 7 ▶ && ( $stream_dep == 0 || exists $self->{streams}->{$stream_dep} )
Branch: 1 branch
BranchTrueFalseTotal
unless exists $self->{"streams"}{$stream_id} and $stream_dep == 0 || exists $self->{"streams"}{$stream_dep} and $stream_id != $stream_dep 0 7 7
Condition44%4/9
exists $self->{"streams"}{$stream_id} and $stream_dep == 0 || exists $self->{"streams"}{$stream_dep} and $stream_id != $stream_dep
!ll&&!rl&&r
007
exists $self->{"streams"}{$stream_id} and $stream_dep == 0 || exists $self->{"streams"}{$stream_dep}
!ll&&!rl&&r
007
$stream_dep == 0 or exists $self->{"streams"}{$stream_dep}
l!l&&r!l&&!r
340
MC/DC0%0/4
exists $self->{"streams"}{$stream_id} and $stream_dep == 0 || exists $self->{"streams"}{$stream_dep} and $stream_id != $stream_dep
exists $self->{"streams"}{$stream_id} $stream_dep == 0 exists $self->{"streams"}{$stream_dep} $stream_id != $stream_dep
Truth table33%2/6
A and B or C and D
A= exists $self->{"streams"}{$stream_id}B= $stream_dep == 0C= exists $self->{"streams"}{$stream_dep}D= $stream_id != $stream_dep
ABCDresult
0XXX0
100X0
11X00
10100
11X11
10111
383 && $stream_id != $stream_dep;
384 7 my $s = $self->{streams};
385  
386 7 ▶ if ( $s->{$stream_id}->{stream_dep} != $stream_dep ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($s->{$stream_id}{"stream_dep"} != $stream_dep) 4 3 7
387  
388 # check if new stream_dep is stream child
389 4 ▶ if ( $stream_dep != 0 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($stream_dep != 0) 4 0 4
390 4 my $sid = $stream_dep;
391 4 ▶ while ( $sid = $s->{$sid}->{stream_dep} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($sid = $s->{$sid}{"stream_dep"}) 5 3 8
392 5 ▶ next unless $sid == $stream_id;
Branch: 1 branch
BranchTrueFalseTotal
unless $sid == $stream_id 4 1 5
393  
394 # Child take my stream dep
395 $s->{$stream_dep}->{stream_dep} =
396 1 $s->{$stream_id}->{stream_dep};
397 1 last;
398 }
399 }
400  
401 # Set new stream dep
402 4 $s->{$stream_id}->{stream_dep} = $stream_dep;
403 }
404  
405 7 ▶ if ($exclusive) {
Branch: 1 branch
BranchTrueFalseTotal
if ($exclusive) 1 6 7
406  
407 # move all siblings to children
408 1 for my $sid ( keys %$s ) {
409 next
410 3 ▶ if $s->{$sid}->{stream_dep} != $stream_dep
Branch: 1 branch
BranchTrueFalseTotal
if $s->{$sid}{"stream_dep"} != $stream_dep or $sid == $stream_id 1 2 3
Condition66%2/3
$s->{$sid}{"stream_dep"} != $stream_dep or $sid == $stream_id
l!l&&r!l&&!r
012
MC/DC50%1/2
$s->{$sid}{"stream_dep"} != $stream_dep or $sid == $stream_id
$s->{$sid}{"stream_dep"} != $stream_dep $sid == $stream_id
Truth table66%2/3
A or B
A= $s->{$sid}{"stream_dep"} != $stream_depB= $sid == $stream_id
ABresult
1X1
011
000
411 || $sid == $stream_id;
412  
413 2 $s->{$sid}->{stream_dep} = $stream_id;
414 }
415 }
416  
417 7 return 1;
418 }
419  
420 1 ▶sub stream_header_block_add {
Subroutine stream_header_block_add: called CC=3 SCAR=12.5
Pod undocumented
421 1 my ( $self, $stream_id, $header_chunk ) = @_;
422 return undef
423 1 ▶ if !exists $self->{streams}->{$stream_id} || !defined $header_chunk;
Branch: 1 branch
BranchTrueFalseTotal
unless exists $self->{"streams"}{$stream_id} and defined $header_chunk 0 1 1
Condition33%1/3
exists $self->{"streams"}{$stream_id} and defined $header_chunk
!ll&&!rl&&r
001
MC/DC0%0/2
exists $self->{"streams"}{$stream_id} and defined $header_chunk
exists $self->{"streams"}{$stream_id} defined $header_chunk
Truth table33%1/3
A and B
A= exists $self->{"streams"}{$stream_id}B= defined $header_chunk
ABresult
0X0
100
111
424 1 $self->{streams}->{$stream_id}->{header_block} .= $header_chunk;
425 }
426  
427 13 1;
« HTTP2/Frame/Push_promise.pm ↑ Summary HTTP2/Frame/Data.pm »