| 1 | package Net::HTTP2::nghttp2::Session; | ||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||
| 3 | 30 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 4 | 30 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 5 | 30 | ▶ | use Carp qw(croak); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 6 | 30 | ▶ | use Scalar::Util qw(weaken); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 7 | 30 | ▶ | use Net::HTTP2::nghttp2; # XS bootstrap (loads _new_server_xs etc.) | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||||||||||||
| 9 | # Session is implemented in XS, this is the Perl-side API wrapper | ||||||||||||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||||||||||
| 11 | 180 | ▶ | sub new_server { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new_server: called CC=12 SCAR=24.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 12 | 180 | my ($class, %args) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||||||||||||||||
| 14 | 180 | ▶ | my $callbacks = delete $args{callbacks} // {}; | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
delete $args{"callbacks"} // {}
MC/DC0%0/1
delete $args{"callbacks"} // {}
delete $args{"callbacks"}
Truth table50%1/2
A
A= delete $args{"callbacks"}
| |||||||||||||||||||||||||||||||||||||||||||
| 15 | 180 | my $user_data = delete $args{user_data}; | |||||||||||||||||||||||||||||||||||||||||
| 16 | 180 | ▶ | my $settings = delete $args{settings} // {}; | ||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
delete $args{"settings"} // {}
MC/DC100%1/1
delete $args{"settings"} // {}
delete $args{"settings"}
Truth table100%2/2
A
A= delete $args{"settings"}
| |||||||||||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||||||||||
| 18 | # Session options (passed to nghttp2_option / nghttp2_session_server_new2) | ||||||||||||||||||||||||||||||||||||||||||
| 19 | 180 | my $max_send_header_block_length = delete $args{max_send_header_block_length}; | |||||||||||||||||||||||||||||||||||||||||
| 20 | 180 | my $stream_reset_burst = delete $args{stream_reset_burst}; | |||||||||||||||||||||||||||||||||||||||||
| 21 | 180 | my $stream_reset_rate = delete $args{stream_reset_rate}; | |||||||||||||||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||||||||||||||||
| 23 | # Validate required callbacks | ||||||||||||||||||||||||||||||||||||||||||
| 24 | 180 | for my $cb (qw(on_begin_headers on_header on_frame_recv)) { | |||||||||||||||||||||||||||||||||||||||||
| 25 | 540 | ▶ | croak "Missing required callback: $cb" unless $callbacks->{$cb}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 26 | } | ||||||||||||||||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||||||||||||||||
| 28 | # Build options hash for XS if any session options are set | ||||||||||||||||||||||||||||||||||||||||||
| 29 | 180 | my %options; | |||||||||||||||||||||||||||||||||||||||||
| 30 | 180 | ▶ | $options{max_send_header_block_length} = $max_send_header_block_length | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 31 | if defined $max_send_header_block_length; | ||||||||||||||||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||||||||||||||||
| 33 | # Rapid Reset (CVE-2023-44487) RST_STREAM rate limit. burst and rate must be | ||||||||||||||||||||||||||||||||||||||||||
| 34 | # set together; they map to nghttp2_option_set_stream_reset_rate_limit. | ||||||||||||||||||||||||||||||||||||||||||
| 35 | 180 | ▶ | if (defined $stream_reset_burst || defined $stream_reset_rate) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
defined $stream_reset_burst or defined $stream_reset_rate
MC/DC100%2/2
defined $stream_reset_burst or defined $stream_reset_rate
defined $stream_reset_burst
defined $stream_reset_rate
Truth table100%3/3
A or B
A= defined $stream_reset_burstB= defined $stream_reset_rate
| |||||||||||||||||||||||||||||||||||||||||||
| 36 | 4 | ▶ | croak "stream_reset_burst and stream_reset_rate must be set together" | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
defined $stream_reset_burst and defined $stream_reset_rate
MC/DC100%2/2
defined $stream_reset_burst and defined $stream_reset_rate
defined $stream_reset_burst
defined $stream_reset_rate
Truth table100%3/3
A and B
A= defined $stream_reset_burstB= defined $stream_reset_rate
| |||||||||||||||||||||||||||||||||||||||||||
| 37 | unless defined $stream_reset_burst && defined $stream_reset_rate; | ||||||||||||||||||||||||||||||||||||||||||
| 38 | 2 | $options{stream_reset_burst} = $stream_reset_burst; | |||||||||||||||||||||||||||||||||||||||||
| 39 | 2 | $options{stream_reset_rate} = $stream_reset_rate; | |||||||||||||||||||||||||||||||||||||||||
| 40 | } | ||||||||||||||||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||||||||||||||||
| 42 | # Create the session via XS | ||||||||||||||||||||||||||||||||||||||||||
| 43 | 178 | ▶ | my $self = %options | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 44 | ? $class->_new_server_xs($callbacks, $user_data, \%options) | ||||||||||||||||||||||||||||||||||||||||||
| 45 | : $class->_new_server_xs($callbacks, $user_data); | ||||||||||||||||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||||||||||||||||
| 47 | # Apply initial settings | ||||||||||||||||||||||||||||||||||||||||||
| 48 | 178 | ▶ | if (%$settings) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 49 | 3 | $self->submit_settings($settings); | |||||||||||||||||||||||||||||||||||||||||
| 50 | } | ||||||||||||||||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||||||||||||||||
| 52 | 178 | return $self; | |||||||||||||||||||||||||||||||||||||||||
| 53 | } | ||||||||||||||||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||||||||||||||||
| 55 | 98 | ▶ | sub new_client { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new_client: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 56 | 98 | my ($class, %args) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||||||||||||||||
| 58 | 98 | ▶ | my $callbacks = delete $args{callbacks} // {}; | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
delete $args{"callbacks"} // {}
MC/DC0%0/1
delete $args{"callbacks"} // {}
delete $args{"callbacks"}
Truth table50%1/2
A
A= delete $args{"callbacks"}
| |||||||||||||||||||||||||||||||||||||||||||
| 59 | 98 | my $user_data = delete $args{user_data}; | |||||||||||||||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||||||||||||||||
| 61 | 98 | return $class->_new_client_xs($callbacks, $user_data); | |||||||||||||||||||||||||||||||||||||||||
| 62 | } | ||||||||||||||||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||||||||||||||||
| 64 | # High-level request submission (client-side) | ||||||||||||||||||||||||||||||||||||||||||
| 65 | # Body can be: undef (no body), string (static body), or CODE ref (streaming callback). | ||||||||||||||||||||||||||||||||||||||||||
| 66 | # Streaming callback receives ($stream_id, $max_length) and returns: | ||||||||||||||||||||||||||||||||||||||||||
| 67 | # ($data, $eof_flag) - send data; EOF ends the stream | ||||||||||||||||||||||||||||||||||||||||||
| 68 | # ($data, $eof_flag, $no_end_stream) - EOF without DATA END_STREAM for trailers | ||||||||||||||||||||||||||||||||||||||||||
| 69 | # undef or an empty list - defer; resume or submit data later | ||||||||||||||||||||||||||||||||||||||||||
| 70 | 2325 | ▶ | sub submit_request { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
submit_request: called CC=6 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 71 | 2325 | my ($self, %args) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||||||||||||||||
| 73 | 2325 | ▶ | my $method = delete $args{method} // 'GET'; | ||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
delete $args{"method"} // "GET"
MC/DC100%1/1
delete $args{"method"} // "GET"
delete $args{"method"}
Truth table100%2/2
A
A= delete $args{"method"}
| |||||||||||||||||||||||||||||||||||||||||||
| 74 | 2325 | ▶ | my $path = delete $args{path} // '/'; | ||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
delete $args{"path"} // "/"
MC/DC100%1/1
delete $args{"path"} // "/"
delete $args{"path"}
Truth table100%2/2
A
A= delete $args{"path"}
| |||||||||||||||||||||||||||||||||||||||||||
| 75 | 2325 | ▶ | my $scheme = delete $args{scheme} // 'https'; | ||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
delete $args{"scheme"} // "https"
MC/DC100%1/1
delete $args{"scheme"} // "https"
delete $args{"scheme"}
Truth table100%2/2
A
A= delete $args{"scheme"}
| |||||||||||||||||||||||||||||||||||||||||||
| 76 | 2325 | my $authority = delete $args{authority}; | |||||||||||||||||||||||||||||||||||||||||
| 77 | 2325 | ▶ | my $headers = delete $args{headers} // []; | ||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
delete $args{"headers"} // []
MC/DC100%1/1
delete $args{"headers"} // []
delete $args{"headers"}
Truth table100%2/2
A
A= delete $args{"headers"}
| |||||||||||||||||||||||||||||||||||||||||||
| 78 | 2325 | my $body = delete $args{body}; | |||||||||||||||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||||||||||||||||
| 80 | # Build pseudo-headers + regular headers | ||||||||||||||||||||||||||||||||||||||||||
| 81 | 2325 | my @nv = ( | |||||||||||||||||||||||||||||||||||||||||
| 82 | [':method', $method], | ||||||||||||||||||||||||||||||||||||||||||
| 83 | [':path', $path], | ||||||||||||||||||||||||||||||||||||||||||
| 84 | [':scheme', $scheme], | ||||||||||||||||||||||||||||||||||||||||||
| 85 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 86 | 2325 | ▶ | push @nv, [':authority', $authority] if defined $authority; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 87 | 2325 | push @nv, @$headers; | |||||||||||||||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||||||||||||||||
| 89 | 2325 | return $self->_submit_request_xs(\@nv, $body); | |||||||||||||||||||||||||||||||||||||||||
| 90 | } | ||||||||||||||||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||||||||||||||||
| 92 | # Convenience method to send server connection preface (SETTINGS frame) | ||||||||||||||||||||||||||||||||||||||||||
| 93 | 275 | ▶ | sub send_connection_preface { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
send_connection_preface: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 94 | 275 | my ($self, %settings) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||||||||||||||||
| 96 | # Default settings for server | ||||||||||||||||||||||||||||||||||||||||||
| 97 | 275 | ▶ | %settings = ( | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 98 | max_concurrent_streams => 100, | ||||||||||||||||||||||||||||||||||||||||||
| 99 | initial_window_size => 65535, | ||||||||||||||||||||||||||||||||||||||||||
| 100 | %settings, | ||||||||||||||||||||||||||||||||||||||||||
| 101 | ) unless %settings; | ||||||||||||||||||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||||||||||||||||||
| 103 | 275 | return $self->submit_settings(\%settings); | |||||||||||||||||||||||||||||||||||||||||
| 104 | } | ||||||||||||||||||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||||||||||||||||
| 106 | # High-level response submission | ||||||||||||||||||||||||||||||||||||||||||
| 107 | 2291 | ▶ | sub submit_response { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
submit_response: called CC=7 SCAR=19.6
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 108 | 2291 | my ($self, $stream_id, %args) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||||||||||||||||||||
| 110 | 2291 | ▶ | my $status = delete $args{status} // 200; | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
delete $args{"status"} // 200
MC/DC0%0/1
delete $args{"status"} // 200
delete $args{"status"}
Truth table50%1/2
A
A= delete $args{"status"}
| |||||||||||||||||||||||||||||||||||||||||||
| 111 | 2291 | ▶ | my $headers = delete $args{headers} // []; | ||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
delete $args{"headers"} // []
MC/DC100%1/1
delete $args{"headers"} // []
delete $args{"headers"}
Truth table100%2/2
A
A= delete $args{"headers"}
| |||||||||||||||||||||||||||||||||||||||||||
| 112 | 2291 | my $body = delete $args{body}; | |||||||||||||||||||||||||||||||||||||||||
| 113 | 2291 | my $data_cb = delete $args{data_callback}; | |||||||||||||||||||||||||||||||||||||||||
| 114 | 2291 | my $cb_data = delete $args{callback_data}; | |||||||||||||||||||||||||||||||||||||||||
| 115 | |||||||||||||||||||||||||||||||||||||||||||
| 116 | # Build pseudo-headers + regular headers | ||||||||||||||||||||||||||||||||||||||||||
| 117 | 2291 | my @nv = ( | |||||||||||||||||||||||||||||||||||||||||
| 118 | [':status', $status], | ||||||||||||||||||||||||||||||||||||||||||
| 119 | @$headers, | ||||||||||||||||||||||||||||||||||||||||||
| 120 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 121 | |||||||||||||||||||||||||||||||||||||||||||
| 122 | 2291 | ▶ | if (defined $body && !ref($body)) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
Condition100%3/3
defined $body and not ref $body
MC/DC100%2/2
defined $body and not ref $body
defined $body
not ref $body
Truth table100%3/3
A and not(B)
A= defined $bodyB= not ref $body
| |||||||||||||||||||||||||||||||||||||||||||
| 123 | # Static body - convert to simple streaming callback | ||||||||||||||||||||||||||||||||||||||||||
| 124 | 38 | my $sent = 0; | |||||||||||||||||||||||||||||||||||||||||
| 125 | 38 | my $body_bytes = $body; | |||||||||||||||||||||||||||||||||||||||||
| 126 | 37 | ▶ | $data_cb = sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=7.0
| |||||||||||||||||||||||||||||||||||||||||||
| 127 | 37 | my ($stream_id, $max_len) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 128 | 37 | ▶ | return ('', 1) if $sent; # EOF | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 129 | 37 | $sent = 1; | |||||||||||||||||||||||||||||||||||||||||
| 130 | 37 | return ($body_bytes, 1); # data + EOF | |||||||||||||||||||||||||||||||||||||||||
| 131 | 38 | }; | |||||||||||||||||||||||||||||||||||||||||
| 132 | 38 | return $self->_submit_response_streaming($stream_id, \@nv, $data_cb, undef); | |||||||||||||||||||||||||||||||||||||||||
| 133 | } | ||||||||||||||||||||||||||||||||||||||||||
| 134 | elsif (ref($body) eq 'CODE') { | ||||||||||||||||||||||||||||||||||||||||||
| 135 | # CODE ref body - streaming callback data provider | ||||||||||||||||||||||||||||||||||||||||||
| 136 | 2249 | return $self->_submit_response_streaming($stream_id, \@nv, $body, $cb_data); | |||||||||||||||||||||||||||||||||||||||||
| 137 | } | ||||||||||||||||||||||||||||||||||||||||||
| 138 | elsif ($data_cb) { | ||||||||||||||||||||||||||||||||||||||||||
| 139 | # Dynamic body - use callback-based data provider | ||||||||||||||||||||||||||||||||||||||||||
| 140 | 4 | return $self->_submit_response_streaming($stream_id, \@nv, $data_cb, $cb_data); | |||||||||||||||||||||||||||||||||||||||||
| 141 | } | ||||||||||||||||||||||||||||||||||||||||||
| 142 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 143 | # No body (e.g., 204 No Content, redirects) | ||||||||||||||||||||||||||||||||||||||||||
| 144 | 0 | return $self->_submit_response_no_body($stream_id, \@nv); | |||||||||||||||||||||||||||||||||||||||||
| 145 | } | ||||||||||||||||||||||||||||||||||||||||||
| 146 | } | ||||||||||||||||||||||||||||||||||||||||||
| 147 | |||||||||||||||||||||||||||||||||||||||||||
| 148 | # Croak, naming the method, unless $headers is a list of [name, value] | ||||||||||||||||||||||||||||||||||||||||||
| 149 | # pairs of defined non-reference scalars. | ||||||||||||||||||||||||||||||||||||||||||
| 150 | 25 | ▶ | sub _check_header_pairs { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_check_header_pairs: called CC=9 SCAR=22.0
| |||||||||||||||||||||||||||||||||||||||||||
| 151 | 25 | my ($method, $headers) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 152 | |||||||||||||||||||||||||||||||||||||||||||
| 153 | 25 | ▶ | croak "$method: headers must be an array reference" | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 154 | unless ref($headers) eq 'ARRAY'; | ||||||||||||||||||||||||||||||||||||||||||
| 155 | |||||||||||||||||||||||||||||||||||||||||||
| 156 | 23 | for my $index (0 .. $#$headers) { | |||||||||||||||||||||||||||||||||||||||||
| 157 | 24 | my $pair = $headers->[$index]; | |||||||||||||||||||||||||||||||||||||||||
| 158 | 24 | ▶ | croak "$method: header $index must be a two-element array reference" | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
ref $pair eq "ARRAY" and @$pair == 2
MC/DC100%2/2
ref $pair eq "ARRAY" and @$pair == 2
ref $pair eq "ARRAY"
@$pair == 2
Truth table100%3/3
A and B
A= ref $pair eq "ARRAY"B= @$pair == 2
| |||||||||||||||||||||||||||||||||||||||||||
| 159 | unless ref($pair) eq 'ARRAY' && @$pair == 2; | ||||||||||||||||||||||||||||||||||||||||||
| 160 | |||||||||||||||||||||||||||||||||||||||||||
| 161 | 20 | my ($name, $value) = @$pair; | |||||||||||||||||||||||||||||||||||||||||
| 162 | 20 | ▶ | croak "$method: header $index name must be a defined non-reference scalar" | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $name and not ref $name
MC/DC50%1/2
defined $name and not ref $name
defined $name
not ref $name
Truth table66%2/3
A and not(B)
A= defined $nameB= not ref $name
| |||||||||||||||||||||||||||||||||||||||||||
| 163 | unless defined($name) && !ref($name); | ||||||||||||||||||||||||||||||||||||||||||
| 164 | 18 | ▶ | croak "$method: header $index value must be a defined non-reference scalar" | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $value and not ref $value
MC/DC50%1/2
defined $value and not ref $value
defined $value
not ref $value
Truth table66%2/3
A and not(B)
A= defined $valueB= not ref $value
| |||||||||||||||||||||||||||||||||||||||||||
| 165 | unless defined($value) && !ref($value); | ||||||||||||||||||||||||||||||||||||||||||
| 166 | } | ||||||||||||||||||||||||||||||||||||||||||
| 167 | 15 | return; | |||||||||||||||||||||||||||||||||||||||||
| 168 | } | ||||||||||||||||||||||||||||||||||||||||||
| 169 | |||||||||||||||||||||||||||||||||||||||||||
| 170 | 17 | ▶ | sub submit_trailer { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
submit_trailer: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 171 | 17 | my ($self, $stream_id, %args) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 172 | |||||||||||||||||||||||||||||||||||||||||||
| 173 | 17 | ▶ | my $headers = delete($args{headers}) // []; | ||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
delete $args{"headers"} // []
MC/DC100%1/1
delete $args{"headers"} // []
delete $args{"headers"}
Truth table100%2/2
A
A= delete $args{"headers"}
| |||||||||||||||||||||||||||||||||||||||||||
| 174 | 17 | _check_header_pairs('submit_trailer', $headers); | |||||||||||||||||||||||||||||||||||||||||
| 175 | 12 | for my $index (0 .. $#$headers) { | |||||||||||||||||||||||||||||||||||||||||
| 176 | 12 | ▶ | croak "submit_trailer: header $index must not use a pseudo-header name" | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 177 | if $headers->[$index][0] =~ /^:/; | ||||||||||||||||||||||||||||||||||||||||||
| 178 | } | ||||||||||||||||||||||||||||||||||||||||||
| 179 | |||||||||||||||||||||||||||||||||||||||||||
| 180 | 11 | return $self->_submit_trailer_xs($stream_id, $headers); | |||||||||||||||||||||||||||||||||||||||||
| 181 | } | ||||||||||||||||||||||||||||||||||||||||||
| 182 | |||||||||||||||||||||||||||||||||||||||||||
| 183 | 8 | ▶ | sub submit_headers { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
submit_headers: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 184 | 8 | my ($self, $stream_id, %args) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 185 | |||||||||||||||||||||||||||||||||||||||||||
| 186 | 8 | ▶ | my $headers = delete($args{headers}) // []; | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
delete $args{"headers"} // []
MC/DC0%0/1
delete $args{"headers"} // []
delete $args{"headers"}
Truth table50%1/2
A
A= delete $args{"headers"}
| |||||||||||||||||||||||||||||||||||||||||||
| 187 | 8 | _check_header_pairs('submit_headers', $headers); | |||||||||||||||||||||||||||||||||||||||||
| 188 | |||||||||||||||||||||||||||||||||||||||||||
| 189 | 3 | ▶ | return $self->_submit_headers_xs($stream_id, $headers, delete($args{end_stream}) ? 1 : 0); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 190 | } | ||||||||||||||||||||||||||||||||||||||||||
| 191 | |||||||||||||||||||||||||||||||||||||||||||
| 192 | 8 | ▶ | sub submit_goaway { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
submit_goaway: called CC=6 SCAR=18.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 193 | 8 | my ($self, %args) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 194 | |||||||||||||||||||||||||||||||||||||||||||
| 195 | 8 | my $last_stream_id = delete $args{last_stream_id}; | |||||||||||||||||||||||||||||||||||||||||
| 196 | 8 | ▶ | croak 'submit_goaway: last_stream_id is required' | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 197 | unless defined $last_stream_id; | ||||||||||||||||||||||||||||||||||||||||||
| 198 | 7 | ▶ | croak 'submit_goaway: last_stream_id must be an integer in 0 .. 0x7FFFFFFF' | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition83%5/6
$last_stream_id =~ /\A-?\d+\z/ and $last_stream_id >= 0 and $last_stream_id <= 2147483647
$last_stream_id =~ /\A-?\d+\z/ and $last_stream_id >= 0
MC/DC66%2/3
$last_stream_id =~ /\A-?\d+\z/ and $last_stream_id >= 0 and $last_stream_id <= 2147483647
$last_stream_id =~ /\A-?\d+\z/
$last_stream_id >= 0
$last_stream_id <= 2147483647
Truth table75%3/4
A and B and C
A= $last_stream_id =~ /\A-?\d+\z/B= $last_stream_id >= 0C= $last_stream_id <= 2147483647
| |||||||||||||||||||||||||||||||||||||||||||
| 199 | unless $last_stream_id =~ /\A-?\d+\z/ | ||||||||||||||||||||||||||||||||||||||||||
| 200 | && $last_stream_id >= 0 && $last_stream_id <= 0x7FFFFFFF; | ||||||||||||||||||||||||||||||||||||||||||
| 201 | |||||||||||||||||||||||||||||||||||||||||||
| 202 | 5 | ▶ | my $error_code = delete($args{error_code}) // Net::HTTP2::nghttp2::NGHTTP2_NO_ERROR(); | ||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
delete $args{"error_code"} // Net::HTTP2::nghttp2::NGHTTP2_NO_ERROR()
MC/DC0%0/2
delete $args{"error_code"} // Net::HTTP2::nghttp2::NGHTTP2_NO_ERROR()
delete $args{"error_code"}
Net::HTTP2::nghttp2::NGHTTP2_NO_ERROR()
Truth table66%2/3
A // B
A= delete $args{"error_code"}B= Net::HTTP2::nghttp2::NGHTTP2_NO_ERROR()
| |||||||||||||||||||||||||||||||||||||||||||
| 203 | 5 | my $opaque_data = delete $args{opaque_data}; | |||||||||||||||||||||||||||||||||||||||||
| 204 | |||||||||||||||||||||||||||||||||||||||||||
| 205 | 5 | return $self->_submit_goaway_xs($last_stream_id, $error_code, $opaque_data); | |||||||||||||||||||||||||||||||||||||||||
| 206 | } | ||||||||||||||||||||||||||||||||||||||||||
| 207 | |||||||||||||||||||||||||||||||||||||||||||
| 208 | # Resume a deferred stream (call after data becomes available) | ||||||||||||||||||||||||||||||||||||||||||
| 209 | 2 | ▶ | sub resume_stream { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
resume_stream: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 210 | 2 | my ($self, $stream_id) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 211 | 2 | $self->_clear_deferred($stream_id); | |||||||||||||||||||||||||||||||||||||||||
| 212 | 2 | return $self->resume_data($stream_id); | |||||||||||||||||||||||||||||||||||||||||
| 213 | } | ||||||||||||||||||||||||||||||||||||||||||
| 214 | |||||||||||||||||||||||||||||||||||||||||||
| 215 | 30 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 216 | |||||||||||||||||||||||||||||||||||||||||||
| 217 | __END__ | ||||||||||||||||||||||||||||||||||||||||||