HTTP/_Transport.pm

filter: Statementstmt 73.4% 72 / 98 Branchbran 41.6% 30 / 72 Conditioncond 23.0% 9 / 39 MC/DCmcdc 4.5% 1 / 22 Subroutinesub 83.3% 15 / 18 Podpod 55.5% 5 / 9 totaltotal 51.1% 132 / 258 CC 50 SCAR 31.3
CC
50
Cov
53%
_http_maybe_finish
72.0
__ANON__
56.0
on_ready
23.3
CRAP 22.9
« HTTP/_Stream.pm ↑ Summary HTTP/_Config.pm »
1 package Linux::Event::HTTP::_Transport;
2 20 ▶use v5.36;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 20 ▶use parent 'Linux::Event::IO::Sock::Stream';
Subroutine BEGIN: called CC=1 SCAR=0.0
4 20 ▶use Scalar::Util qw(weaken blessed);
Subroutine BEGIN: called CC=1 SCAR=0.0
5 20 ▶use Carp qw(croak);
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 28 ▶sub on_ready ($self) {
Subroutine on_ready: called CC=12 SCAR=31.5
Pod documented
8 28 my $state = $self->data;
9 28 ▶ if (my $ready = delete $state->{ready}) {
Branch: 2 branches
BranchTrueFalseTotal
if (my $ready = delete $state->{'ready'}) { } 10 18 28
elsif (my $server = $state->{'server'}) { } 18 0 18
10 my $engine = $ready->(
11 transport => $self, alpn => $self->selected_alpn,
12 10 ▶ verified_origin => $state->{verified_origin} ? 1 : 0,
Branch: 1 branch
BranchTrueFalseTotal
$state->{'verified_origin'} ? : 1 9 10
13 );
14 10 ▶ if ($self->is_closed) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->is_closed) 0 10 10
15 0 ▶ $engine->transport_error('HTTP transport closed during attachment') if $engine;
Branch: 1 branch
BranchTrueFalseTotal
if $engine 0 0 0
16 0 return;
17 }
18 10 $self->{http_engine} = $engine;
19 10 ▶ $self->{http_multiplexed} = $engine && $engine->isa('Unblock::HTTP2::_Connection');
Condition33%1/3
$engine && $engine->isa('Unblock::HTTP2::_Connection')
!ll&&!rl&&r
0100
MC/DC0%0/2
$engine && $engine->isa('Unblock::HTTP2::_Connection')
$engine $engine->isa('Unblock::HTTP2::_Connection')
Truth table33%1/3
A && B
A= $engineB= $engine->isa('Unblock::HTTP2::_Connection')
ABresult
0X0
100
111
20 10 ▶ $self->close unless $engine;
Branch: 1 branch
BranchTrueFalseTotal
unless $engine 0 10 10
21 } elsif (my $server = $state->{server}) {
22 18 my $engine = $server->_attach($self);
23 18 ▶ if ($self->is_closed) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->is_closed) 0 18 18
24 0 ▶ $engine->transport_error('HTTP transport closed during attachment') if $engine;
Branch: 1 branch
BranchTrueFalseTotal
if $engine 0 0 0
25 0 return;
26 }
27 18 $self->{http_engine} = $engine;
28 18 ▶ $self->{http_multiplexed} = $engine && $engine->isa('Unblock::HTTP2::_Connection');
Condition33%1/3
$engine && $engine->isa('Unblock::HTTP2::_Connection')
!ll&&!rl&&r
0180
MC/DC0%0/2
$engine && $engine->isa('Unblock::HTTP2::_Connection')
$engine $engine->isa('Unblock::HTTP2::_Connection')
Truth table33%1/3
A && B
A= $engineB= $engine->isa('Unblock::HTTP2::_Connection')
ABresult
0X0
100
111
29 18 ▶ $self->close unless $engine;
Branch: 1 branch
BranchTrueFalseTotal
unless $engine 0 18 18
30 } else {
31 0 $self->close;
32 }
33 28 return;
34 }
35  
36 8 ▶sub on_eof ($self) {
Subroutine on_eof: called CC=3 SCAR=11.0
Pod documented
37 8 my $engine = $self->{http_engine};
38 8 ▶ $engine->input_eof if $engine && $engine->want_read;
Branch: 1 branch
BranchTrueFalseTotal
if $engine and $engine->want_read 3 5 8
Condition66%2/3
$engine and $engine->want_read
!ll&&!rl&&r
053
MC/DC50%1/2
$engine and $engine->want_read
$engine $engine->want_read
Truth table66%2/3
A and B
A= $engineB= $engine->want_read
ABresult
0X0
100
111
39 8 return;
40 }
41  
42 39 ▶sub on_drain ($self) {
Subroutine on_drain: called CC=1 SCAR=0.0
Pod documented
43 39 $self->{http_output_blocked} = 0;
44 39 $self->_http_flush;
45 39 return;
46 }
47  
48 39 ▶sub _http_flush ($self) {
Subroutine _http_flush: called CC=5 SCAR=18.1
49 39 ▶ return if $self->is_closed || $self->{http_output_blocked};
Branch: 1 branch
BranchTrueFalseTotal
if $self->is_closed or $self->{"http_output_blocked"} 0 39 39
Condition33%1/3
$self->is_closed or $self->{"http_output_blocked"}
l!l&&r!l&&!r
0039
MC/DC0%0/2
$self->is_closed or $self->{"http_output_blocked"}
$self->is_closed $self->{"http_output_blocked"}
Truth table33%1/3
A or B
A= $self->is_closedB= $self->{"http_output_blocked"}
ABresult
1X1
011
000
50 39 my $engine = $self->{http_engine};
51 39 ▶ $engine->resume_output if $engine;
Branch: 1 branch
BranchTrueFalseTotal
if $engine 39 0 39
52 39 ▶ $self->_http_maybe_finish if $self->{http_multiplexed};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"http_multiplexed"} 0 39 39
53 39 return;
54 }
55  
56 0 ▶sub _http_maybe_finish ($self) {
Subroutine _http_maybe_finish: not called CC=8 SCAR=42.8
57 0 ▶ return unless $self->{http_multiplexed};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"http_multiplexed"} 0 0 0
58 0 ▶ return if $self->is_closed || $self->{http_output_blocked} || $self->{http_finish_scheduled};
Branch: 1 branch
BranchTrueFalseTotal
if $self->is_closed or $self->{"http_output_blocked"} or $self->{"http_finish_scheduled"} 0 0 0
Condition0%0/6
$self->is_closed or $self->{"http_output_blocked"} or $self->{"http_finish_scheduled"}
l!l&&r!l&&!r
000
$self->is_closed or $self->{"http_output_blocked"}
l!l&&r!l&&!r
000
MC/DC0%0/3
$self->is_closed or $self->{"http_output_blocked"} or $self->{"http_finish_scheduled"}
$self->is_closed $self->{"http_output_blocked"} $self->{"http_finish_scheduled"}
Truth table0%0/4
A or B or C
A= $self->is_closedB= $self->{"http_output_blocked"}C= $self->{"http_finish_scheduled"}
ABCresult
1XX1
01X1
0011
0000
59 0 ▶ my $engine = $self->{http_engine} or return;
Branch: 1 branch
BranchTrueFalseTotal
my $engine = $self->{"http_engine"} or return 0 0 0
60 0 ▶ return if $engine->want_read || $engine->want_write;
Branch: 1 branch
BranchTrueFalseTotal
if $engine->want_read or $engine->want_write 0 0 0
Condition0%0/3
$engine->want_read or $engine->want_write
l!l&&r!l&&!r
000
MC/DC0%0/2
$engine->want_read or $engine->want_write
$engine->want_read $engine->want_write
Truth table0%0/3
A or B
A= $engine->want_readB= $engine->want_write
ABresult
1X1
011
000
61 # nghttp2 has no further input or output after its final GOAWAY/stream.
62 # End outside protocol callbacks, preserving bytes already in our queue.
63 0 $self->{http_finish_scheduled} = 1;
64 0 my $weak = $self;
65 0 weaken($weak);
66 0 ▶ $self->loop->defer(sub {
Subroutine __ANON__: not called CC=7 SCAR=40.3
67 0 ▶ my $stream = $weak or return;
Branch: 1 branch
BranchTrueFalseTotal
my $stream = $weak or return 0 0 0
68 0 delete $stream->{http_finish_scheduled};
69 0 ▶ return if $stream->is_closed || $stream->{http_output_blocked};
Branch: 1 branch
BranchTrueFalseTotal
if $stream->is_closed or $stream->{"http_output_blocked"} 0 0 0
Condition0%0/3
$stream->is_closed or $stream->{"http_output_blocked"}
l!l&&r!l&&!r
000
MC/DC0%0/2
$stream->is_closed or $stream->{"http_output_blocked"}
$stream->is_closed $stream->{"http_output_blocked"}
Truth table0%0/3
A or B
A= $stream->is_closedB= $stream->{"http_output_blocked"}
ABresult
1X1
011
000
70 0 ▶ my $engine = $stream->{http_engine} or return;
Branch: 1 branch
BranchTrueFalseTotal
my $engine = $stream->{"http_engine"} or return 0 0 0
71 0 ▶ $stream->end unless $engine->want_read || $engine->want_write;
Branch: 1 branch
BranchTrueFalseTotal
unless $engine->want_read or $engine->want_write 0 0 0
Condition0%0/3
$engine->want_read or $engine->want_write
l!l&&r!l&&!r
000
MC/DC0%0/2
$engine->want_read or $engine->want_write
$engine->want_read $engine->want_write
Truth table0%0/3
A or B
A= $engine->want_readB= $engine->want_write
ABresult
1X1
011
000
72 0 });
73 0 return;
74 }
75  
76 8 ▶sub _http_drain ($self) {
Subroutine _http_drain: called CC=2 SCAR=6.9
77 8 ▶ if (my $engine = $self->{http_engine}) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $engine = $self->{'http_engine'}) { } 4 4 8
78 4 $engine->drain;
79 } else {
80 # No admitted HTTP request exists during a TLS handshake.
81 4 $self->close;
82 }
83 8 return;
84 }
85  
86 2 ▶sub on_error ($self, $error) {
Subroutine on_error: called CC=3 SCAR=11.3
Pod documented
87 2 ▶ if (my $ready = delete $self->data->{ready}) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $ready = delete $self->data->{"ready"}) 2 0 2
88 2 $ready->(error => "$error");
89 }
90 2 my $engine = $self->{http_engine};
91 2 ▶ $engine->transport_error("$error") if $engine;
Branch: 1 branch
BranchTrueFalseTotal
if $engine 0 2 2
92 2 return;
93 }
94  
95 0 ▶sub _http_input_failed ($self, $error) {
Subroutine _http_input_failed: not called CC=3 SCAR=24.8
96 0 my $engine = $self->{http_engine};
97 0 ▶ $engine->transport_error($error) if $engine;
Branch: 1 branch
BranchTrueFalseTotal
if $engine 0 0 0
98 0 ▶ $self->close unless $self->is_closed;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->is_closed 0 0 0
99 0 return;
100 }
101  
102 29 ▶sub on_close ($self) {
Subroutine on_close: called CC=4 SCAR=14.0
Pod documented
103 # Remove before notifying: transport_error may call unblock_abort again.
104 29 my $engine = delete $self->{http_engine};
105 29 my $state = $self->data;
106 29 ▶ $engine->transport_error('HTTP transport closed') if $engine;
Branch: 1 branch
BranchTrueFalseTotal
if $engine 24 5 29
107 29 ▶ if (my $server = $state->{server}) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $server = $state->{"server"}) 18 11 29
108 18 $server->_closed($self);
109 }
110 29 ▶ if (my $ready = delete $state->{ready}) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $ready = delete $state->{"ready"}) 0 29 29
111 0 $ready->(error => 'HTTP transport closed before readiness');
112 }
113 29 return;
114 }
115  
116 # Unblock::HTTP owns the HTTP1 handshake and the successor protocol.
117 # This is a socket-wide (never H2/H3 stream-local) transition. Linux::Event
118 # retains the write queue and, for native input, the unread borrowed tail.
119 4 ▶sub unblock_upgrade ($self, $successor) {
Subroutine unblock_upgrade: called CC=10 SCAR=28.1
Pod undocumented
120 4 ▶ croak 'unblock_upgrade(): requires an established protocol consumer'
Branch: 1 branch
BranchTrueFalseTotal
unless builtin::blessed($successor) and $successor->can("input") and $successor->can("input_eof") and $successor->can("transport_error") and $successor->can("resume_output") 0 4 4
Condition33%4/12
builtin::blessed($successor) and $successor->can("input") and $successor->can("input_eof") and $successor->can("transport_error") and $successor->can("resume_output")
!ll&&!rl&&r
004
builtin::blessed($successor) and $successor->can("input") and $successor->can("input_eof") and $successor->can("transport_error")
!ll&&!rl&&r
004
builtin::blessed($successor) and $successor->can("input") and $successor->can("input_eof")
!ll&&!rl&&r
004
builtin::blessed($successor) and $successor->can("input")
!ll&&!rl&&r
004
MC/DC0%0/5
builtin::blessed($successor) and $successor->can("input") and $successor->can("input_eof") and $successor->can("transport_error") and $successor->can("resume_output")
builtin::blessed($successor) $successor->can("input") $successor->can("input_eof") $successor->can("transport_error") $successor->can("resume_output")
Truth table16%1/6
A and B and C and D and E
A= builtin::blessed($successor)B= $successor->can("input")C= $successor->can("input_eof")D= $successor->can("transport_error")E= $successor->can("resume_output")
ABCDEresult
0XXXX0
10XXX0
110XX0
1110X0
111100
111111
121 unless blessed($successor)
122 && $successor->can('input') && $successor->can('input_eof')
123 && $successor->can('transport_error')
124 && $successor->can('resume_output');
125 croak 'unblock_upgrade(): socket already upgraded'
126 4 ▶ if $self->{http_successor};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"http_successor"} 0 4 4
127 croak 'unblock_upgrade(): multiplexed HTTP cannot transfer the socket'
128 4 ▶ if $self->{http_multiplexed};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"http_multiplexed"} 0 4 4
129 croak 'unblock_upgrade(): no HTTP engine is attached'
130 4 ▶ unless $self->{http_engine};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"http_engine"} 0 4 4
131 4 require Linux::Event::HTTP::_UpgradedStream;
132 4 $self->{http_successor} = $successor;
133 4 my $ok = eval {
134 4 $self->transition_to('Linux::Event::HTTP::_UpgradedStream');
135 4 1;
136 };
137 4 ▶ unless ($ok) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($ok) 0 4 4
138 0 delete $self->{http_successor};
139 0 die $@;
140 }
141 4 delete $self->{http_engine};
142 4 delete $self->{http_multiplexed};
143 4 return;
144 }
145  
146 165 ▶sub unblock_send ($self, $bytes) {
Subroutine unblock_send: called CC=3 SCAR=11.3
Pod undocumented
147 165 my $ready = $self->write($bytes);
148 165 ▶ die "HTTP transport closed during output\n" if $self->is_closed;
Branch: 1 branch
BranchTrueFalseTotal
if $self->is_closed 0 165 165
149 165 $self->{http_output_blocked} = !$ready;
150 165 ▶ $self->_http_maybe_finish if $self->{http_multiplexed};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"http_multiplexed"} 0 165 165
151 165 return $ready;
152 }
153  
154 8 ▶sub unblock_finish ($self) { $self->end }
Subroutine unblock_finish: called CC=1 SCAR=0.0
Pod undocumented
155 24 ▶sub unblock_abort ($self, $reason) { $self->close }
Subroutine unblock_abort: called CC=1 SCAR=0.0
Pod undocumented
156  
157 20 1;
« HTTP/_Stream.pm ↑ Summary HTTP/_Config.pm »