| 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
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | $self->{last_stream} += 2 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | 43 | ▶ | if exists $self->{streams}->{ $self->{type} == CLIENT ? 1 : 2 }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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
Condition33%1/3
$stream_id < $self->{"last_peer_stream"} or $stream_id % 2 == ($self->{"type"} == 1)
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)
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | 158 | my $s = $self->{streams}->{$stream_id}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | 158 | ▶ | if (@_) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | 158 | my ( $new_state, $pending ) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | 158 | ▶ | if ($pending) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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
Condition100%3/3
exists $s->{"cb"} and exists $s->{"cb"}{$s->{"state"}}
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"}}
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | $self->{active_peer_streams}-- | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | if $self->{active_peer_streams} | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | 71 | ▶ | && ( ( $stream_id % 2 ) ^ ( $self->{type} == CLIENT ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$self->{"active_peer_streams"} and $stream_id % 2 ^ $self->{"type"} == 1
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
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | 266 | my $s = $self->{streams}->{$stream_id}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | 266 | ▶ | if (@_) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | 6 | $s->{pending_state} = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | $self->{pending_stream} = | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | 6 | ▶ | defined $s->{pending_state} ? $stream_id : undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | 93 | my $s = $self->{streams}->{$stream_id}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | 93 | ▶ | if (@_) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | # Exec callbacks for data | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | 20 | ▶ | if ( exists $s->{frame_cb} && exists $s->{frame_cb}->{&DATA} ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
exists $s->{"frame_cb"} and exists $s->{"frame_cb"}{&DATA}
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}
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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'}
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'}
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | 74 | ▶ | if ( $s->{promised_sid} ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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
Condition66%2/3
exists $s->{"frame_cb"} and exists $s->{"frame_cb"}{&HEADERS}
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}
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | 185 | ▶ | if ( !$pseudo_flag ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | 2060 | ▶ | if ( $h eq 'connection' ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 4 branches
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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"
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"
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 340 | 143 | my $s = $self->{streams}->{$stream_id}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 341 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 342 | 143 | ▶ | if (@_) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 370 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 371 | 3 | ▶ | if ( defined( $s->{blocked_data} ) && length( $s->{blocked_data} ) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%4/6
defined $s->{"blocked_data"} and length $s->{"blocked_data"} and $self->stream_fcw_send($stream_id) > 0
defined $s->{"blocked_data"} and length $s->{"blocked_data"}
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
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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
Condition44%4/9
exists $self->{"streams"}{$stream_id} and $stream_dep == 0 || exists $self->{"streams"}{$stream_dep} and $stream_id != $stream_dep
exists $self->{"streams"}{$stream_id} and $stream_dep == 0 || exists $self->{"streams"}{$stream_dep}
$stream_dep == 0 or exists $self->{"streams"}{$stream_dep}
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
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 387 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 388 | # check if new stream_dep is stream child | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 389 | 4 | ▶ | if ( $stream_dep != 0 ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 390 | 4 | my $sid = $stream_dep; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 391 | 4 | ▶ | while ( $sid = $s->{$sid}->{stream_dep} ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 392 | 5 | ▶ | next unless $sid == $stream_id; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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
Condition66%2/3
$s->{$sid}{"stream_dep"} != $stream_dep or $sid == $stream_id
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
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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
Condition33%1/3
exists $self->{"streams"}{$stream_id} and defined $header_chunk
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
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 424 | 1 | $self->{streams}->{$stream_id}->{header_block} .= $header_chunk; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 425 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 426 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 427 | 13 | 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||