| 1 | package Linux::Event::HTTP::_HTTP2; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | 1 | ▶ | use v5.36; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 1 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | 1 | ▶ | use Scalar::Util qw(blessed); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 1 | ▶ | use Linux::Event::HTTP::Request; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 1 | ▶ | use Linux::Event::HTTP::Response; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 1 | ▶ | use Linux::Event::HTTP::Transaction; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 1 | our $VERSION = '0.003'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | 1 | my %FORBIDDEN = map { $_ => 1 } qw( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | connection | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | keep-alive | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | proxy-connection | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | transfer-encoding | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | upgrade | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | 8 | ▶ | sub _pairs ($operation, $pairs) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_pairs: called CC=9 SCAR=28.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | 8 | ▶ | die "$operation: header block must be an array reference" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | if ref($pairs) ne 'ARRAY'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | 8 | for my $pair (@$pairs) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | 33 | ▶ | die "$operation: each field must be a [name, value] pair" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
ref $pair ne "ARRAY" or @$pair != 2
MC/DC0%0/2
ref $pair ne "ARRAY" or @$pair != 2
ref $pair ne "ARRAY"
@$pair != 2
Truth table33%1/3
A or B
A= ref $pair ne "ARRAY"B= @$pair != 2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | if ref($pair) ne 'ARRAY' || @$pair != 2; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | 33 | ▶ | die "$operation: field name and value must be defined scalars" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%3/9
not defined $pair->[0] or ref $pair->[0] or not defined $pair->[1] or ref $pair->[1]
not defined $pair->[0] or ref $pair->[0] or not defined $pair->[1]
not defined $pair->[0] or ref $pair->[0]
MC/DC0%0/4
not defined $pair->[0] or ref $pair->[0] or not defined $pair->[1] or ref $pair->[1]
not defined $pair->[0]
ref $pair->[0]
not defined $pair->[1]
ref $pair->[1]
Truth table20%1/5
not(A) or B or not(C) or D
A= not defined $pair->[0]B= ref $pair->[0]C= not defined $pair->[1]D= ref $pair->[1]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | if !defined($pair->[0]) || ref($pair->[0]) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | || !defined($pair->[1]) || ref($pair->[1]); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | 8 | return $pairs; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | 9 | ▶ | sub _normal_field ($operation, $name, $value) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_normal_field: called CC=5 SCAR=17.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | 9 | ▶ | die "$operation: HTTP/2 field names must be lowercase" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | if $name ne lc $name; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | 8 | ▶ | if ($FORBIDDEN{$name}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | 1 | die "$operation: HTTP/2 forbids connection-specific field '$name'"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | 7 | ▶ | if ($name eq 'te' && lc($value) ne 'trailers') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$name eq "te" and lc $value ne "trailers"
MC/DC0%0/2
$name eq "te" and lc $value ne "trailers"
$name eq "te"
lc $value ne "trailers"
Truth table33%1/3
A and B
A= $name eq "te"B= lc $value ne "trailers"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | 0 | die "$operation: HTTP/2 TE is limited to trailers"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | 7 | return [ $name, $value ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | 8 | ▶ | sub _split_header_block ($operation, $pairs, $allowed) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_split_header_block: called CC=6 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | 8 | _pairs($operation, $pairs); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | 8 | my %pseudo; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | my @normal; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | 8 | my $saw_normal = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | 8 | for my $pair (@$pairs) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | 31 | my ($name, $value) = @$pair; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | 31 | ▶ | if (substr($name, 0, 1) eq ':') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | 24 | ▶ | die "$operation: pseudo-header follows a regular field" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | if $saw_normal; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | die "$operation: unsupported pseudo-header '$name'" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | 23 | ▶ | if !$allowed->{$name}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | die "$operation: duplicate pseudo-header '$name'" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | 22 | ▶ | if exists $pseudo{$name}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | 22 | $pseudo{$name} = $value; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | 22 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | 7 | $saw_normal = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | 7 | push @normal, _normal_field($operation, $name, $value); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | 4 | return (\%pseudo, \@normal); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | 7 | ▶ | sub request_from_headers ($class, $pairs, %option) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
request_from_headers: called CC=18 SCAR=33.2
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | 7 | ▶ | my $end_stream = delete($option{end_stream}) // 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
delete $option{"end_stream"} // 0
MC/DC100%1/1
delete $option{"end_stream"} // 0
delete $option{"end_stream"}
Truth table100%2/2
A
A= delete $option{"end_stream"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | 7 | ▶ | die 'request_from_headers(): unknown options: ' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | . join(', ', sort keys %option) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | if %option; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | 7 | my ($pseudo, $normal) = _split_header_block( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | 'request_from_headers()', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | $pairs, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | ':method' => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | ':scheme' => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | ':authority' => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | ':path' => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | 3 | my $method = $pseudo->{':method'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | 3 | ▶ | die 'request_from_headers(): missing :method' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
not defined $method or $method eq ""
MC/DC0%0/2
not defined $method or $method eq ""
not defined $method
$method eq ""
Truth table33%1/3
not(A) or B
A= not defined $methodB= $method eq ""
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | if !defined($method) || $method eq ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | 3 | my ($target, $scheme, $authority); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | 3 | ▶ | if (uc($method) eq 'CONNECT') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | die 'request_from_headers(): CONNECT requires :authority' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | if !defined($pseudo->{':authority'}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | 1 | ▶ | || $pseudo->{':authority'} eq ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
not defined $pseudo->{":authority"} or $pseudo->{":authority"} eq ""
MC/DC0%0/2
not defined $pseudo->{":authority"} or $pseudo->{":authority"} eq ""
not defined $pseudo->{":authority"}
$pseudo->{":authority"} eq ""
Truth table33%1/3
not(A) or B
A= not defined $pseudo->{":authority"}B= $pseudo->{":authority"} eq ""
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | die 'request_from_headers(): ordinary CONNECT must omit :scheme and :path' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | 1 | ▶ | if exists($pseudo->{':scheme'}) || exists($pseudo->{':path'}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
exists $pseudo->{":scheme"} or exists $pseudo->{":path"}
MC/DC0%0/2
exists $pseudo->{":scheme"} or exists $pseudo->{":path"}
exists $pseudo->{":scheme"}
exists $pseudo->{":path"}
Truth table33%1/3
A or B
A= exists $pseudo->{":scheme"}B= exists $pseudo->{":path"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | 1 | $authority = $pseudo->{':authority'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | 1 | $target = $authority; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | die 'request_from_headers(): missing :scheme' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | if !defined($pseudo->{':scheme'}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | 2 | ▶ | || $pseudo->{':scheme'} eq ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
not defined $pseudo->{":scheme"} or $pseudo->{":scheme"} eq ""
MC/DC0%0/2
not defined $pseudo->{":scheme"} or $pseudo->{":scheme"} eq ""
not defined $pseudo->{":scheme"}
$pseudo->{":scheme"} eq ""
Truth table33%1/3
not(A) or B
A= not defined $pseudo->{":scheme"}B= $pseudo->{":scheme"} eq ""
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | die 'request_from_headers(): missing :path' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | if !defined($pseudo->{':path'}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | 2 | ▶ | || $pseudo->{':path'} eq ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
not defined $pseudo->{":path"} or $pseudo->{":path"} eq ""
MC/DC0%0/2
not defined $pseudo->{":path"} or $pseudo->{":path"} eq ""
not defined $pseudo->{":path"}
$pseudo->{":path"} eq ""
Truth table33%1/3
not(A) or B
A= not defined $pseudo->{":path"}B= $pseudo->{":path"} eq ""
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | die 'request_from_headers(): missing :authority' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | if !defined($pseudo->{':authority'}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | 2 | ▶ | || $pseudo->{':authority'} eq ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
not defined $pseudo->{":authority"} or $pseudo->{":authority"} eq ""
MC/DC0%0/2
not defined $pseudo->{":authority"} or $pseudo->{":authority"} eq ""
not defined $pseudo->{":authority"}
$pseudo->{":authority"} eq ""
Truth table33%1/3
not(A) or B
A= not defined $pseudo->{":authority"}B= $pseudo->{":authority"} eq ""
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | 2 | $scheme = $pseudo->{':scheme'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | 2 | $authority = $pseudo->{':authority'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | 2 | $target = $pseudo->{':path'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | 3 | ▶ | my $request = Linux::Event::HTTP::Request->new( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | method => $method, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | target => $target, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | version => '2', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | (defined($scheme) ? (scheme => $scheme) : ()), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | authority => $authority, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | headers => $normal, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | 3 | ▶ | $request->_mark_incomplete if !$end_stream; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | 3 | $request->_mark_committed; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | 3 | return $request; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | 1 | ▶ | sub response_from_headers ($class, $pairs, %option) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
response_from_headers: called CC=6 SCAR=19.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | 1 | ▶ | my $end_stream = delete($option{end_stream}) // 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
delete $option{"end_stream"} // 0
MC/DC0%0/1
delete $option{"end_stream"} // 0
delete $option{"end_stream"}
Truth table50%1/2
A
A= delete $option{"end_stream"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | 1 | ▶ | die 'response_from_headers(): unknown options: ' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | . join(', ', sort keys %option) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | if %option; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | 1 | my ($pseudo, $normal) = _split_header_block( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | 'response_from_headers()', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | $pairs, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | { ':status' => 1 }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | 1 | my $status = $pseudo->{':status'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | 1 | ▶ | die 'response_from_headers(): missing :status' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
not defined $status or $status eq ""
MC/DC0%0/2
not defined $status or $status eq ""
not defined $status
$status eq ""
Truth table33%1/3
not(A) or B
A= not defined $statusB= $status eq ""
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | if !defined($status) || $status eq ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | 1 | my $response = Linux::Event::HTTP::Response->new( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | status => $status, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | version => '2', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | headers => $normal, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | 1 | $response->_commit; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | 1 | ▶ | $end_stream ? $response->_mark_complete : $response->_mark_incomplete; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | 1 | return $response; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | 3 | ▶ | sub _outbound_normal_fields ($operation, $message) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_outbound_normal_fields: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | 3 | my @fields; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | 3 | for my $index (0 .. $message->header_count - 1) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | 2 | my $name = lc $message->header_name($index); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | 2 | my $value = $message->header_value($index); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | 2 | push @fields, _normal_field($operation, $name, $value); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | 3 | return @fields; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | 2 | ▶ | sub request_headers ($class, $request) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
request_headers: called CC=12 SCAR=29.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | 2 | ▶ | die 'request_headers(): requires a Linux::Event::HTTP::Request' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
builtin::blessed($request) and $request->isa("Linux::Event::HTTP::Request")
MC/DC0%0/2
builtin::blessed($request) and $request->isa("Linux::Event::HTTP::Request")
builtin::blessed($request)
$request->isa("Linux::Event::HTTP::Request")
Truth table33%1/3
A and B
A= builtin::blessed($request)B= $request->isa("Linux::Event::HTTP::Request")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | if !blessed($request) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | || !$request->isa('Linux::Event::HTTP::Request'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | 2 | ▶ | die 'request_headers(): Request version must be 2' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%1/2
$request->version // ""
MC/DC0%0/1
$request->version // ""
$request->version
Truth table50%1/2
A
A= $request->version
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | if ($request->version // '') ne '2'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | 2 | my @block = ([ ':method', $request->method ]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | 2 | ▶ | if (uc($request->method) eq 'CONNECT') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | 1 | my $authority = $request->authority; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | 1 | ▶ | die 'request_headers(): CONNECT requires authority' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
not defined $authority or $authority eq ""
MC/DC0%0/2
not defined $authority or $authority eq ""
not defined $authority
$authority eq ""
Truth table33%1/3
not(A) or B
A= not defined $authorityB= $authority eq ""
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | if !defined($authority) || $authority eq ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | 1 | push @block, [ ':authority', $authority ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | 1 | my $scheme = $request->scheme; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | 1 | my $authority = $request->authority; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | 1 | ▶ | die 'request_headers(): HTTP/2 Request requires scheme' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
not defined $scheme or $scheme eq ""
MC/DC0%0/2
not defined $scheme or $scheme eq ""
not defined $scheme
$scheme eq ""
Truth table33%1/3
not(A) or B
A= not defined $schemeB= $scheme eq ""
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | if !defined($scheme) || $scheme eq ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | 1 | ▶ | die 'request_headers(): HTTP/2 Request requires authority' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
not defined $authority or $authority eq ""
MC/DC0%0/2
not defined $authority or $authority eq ""
not defined $authority
$authority eq ""
Truth table33%1/3
not(A) or B
A= not defined $authorityB= $authority eq ""
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | if !defined($authority) || $authority eq ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | 1 | push @block, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | [ ':scheme', $scheme ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | [ ':authority', $authority ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | [ ':path', $request->target ]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | 2 | push @block, _outbound_normal_fields('request_headers()', $request); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | 2 | return \@block; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | 1 | ▶ | sub response_headers ($class, $response) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
response_headers: called CC=5 SCAR=18.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | 1 | ▶ | die 'response_headers(): requires a Linux::Event::HTTP::Response' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
builtin::blessed($response) and $response->isa("Linux::Event::HTTP::Response")
MC/DC0%0/2
builtin::blessed($response) and $response->isa("Linux::Event::HTTP::Response")
builtin::blessed($response)
$response->isa("Linux::Event::HTTP::Response")
Truth table33%1/3
A and B
A= builtin::blessed($response)B= $response->isa("Linux::Event::HTTP::Response")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | if !blessed($response) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | || !$response->isa('Linux::Event::HTTP::Response'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | 1 | ▶ | die 'response_headers(): Response version must be 2' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%1/2
$response->version // ""
MC/DC0%0/1
$response->version // ""
$response->version
Truth table50%1/2
A
A= $response->version
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | if ($response->version // '') ne '2'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | 1 | my @block = ([ ':status', '' . $response->status ]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | 1 | push @block, _outbound_normal_fields('response_headers()', $response); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | 1 | return \@block; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | 1 | ▶ | sub server_transaction_from_headers ($class, $pairs, $controller, %option) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
server_transaction_from_headers: called CC=2 SCAR=7.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | 1 | ▶ | die 'server_transaction_from_headers(): controller must be an object' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | if !blessed($controller); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | 1 | my $request = $class->request_from_headers($pairs, %option); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | 1 | my $response = Linux::Event::HTTP::Response->new( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | status => 200, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | version => '2', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | 1 | my $transaction = Linux::Event::HTTP::Transaction->_new( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | request => $request, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | controller => $controller, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | 1 | $transaction->_activate; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | 1 | $transaction->_set_response($response); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | 1 | return $transaction; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | 1 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||