blib/lib/Unblock/HTTP1/Client.pm

filter: Statementstmt 93.7% 343 / 366 Branchbran 71.1% 185 / 260 Conditioncond 57.1% 68 / 119 MC/DCmcdc 32.3% 21 / 65 Subroutinesub 86.2% 25 / 29 Podpod 100% 3 / 3 totaltotal 76.6% 645 / 842 CC 175 SCAR 39.1
CC
175
Cov
80%
_drive
108.8
request
30.0
_transaction_write
18.7
CRAP 50.0
« blib/lib/Unblock/HTTP1/_Wire.pm ↑ Summary blib/lib/Unblock/HTTP1/Server.pm »
1 package Unblock::HTTP1::Client;
2  
3 27 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 27 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 27 ▶use Carp qw(croak);
Subroutine BEGIN: called CC=1 SCAR=0.0
6 27 ▶use parent 'Unblock::HTTP1::_Engine';
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 27 ▶use Uniform::HTTP::Request;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 27 ▶use Uniform::HTTP::Response;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 27 ▶use Unblock::HTTP1::_Native ();
Subroutine BEGIN: called CC=1 SCAR=0.0
11 27 ▶use Unblock::HTTP1::_Wire ();
Subroutine BEGIN: called CC=1 SCAR=0.0
12 27 ▶use Unblock::HTTP1::Transaction;
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 27 our $VERSION = '0.11';
15  
16 63 ▶sub new {
Subroutine new: called CC=1 SCAR=0.0
Pod documented
17 63 my ($class, %option) = @_;
18 63 my $self = bless {
19 queue => [],
20 active => undef,
21 rx => undef,
22 }, $class;
23 63 $self->_init_engine(%option);
24 63 return $self;
25 }
26  
27 71 ▶sub request {
Subroutine request: called CC=23 SCAR=34.0
Pod documented
28 71 my ($self, @arg) = @_;
29 71 ▶ croak 'request(): connection is closed' if $self->{closed};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"closed"} 1 70 71
30 70 ▶ croak 'request(): connection has switched protocols' if $self->{switched};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"switched"} 0 70 70
31 70 ▶ croak 'request(): read side is at EOF' if $self->{eof};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"eof"} 0 70 70
32  
33 70 my ($request, %option);
34 70 ▶ if (@arg && ref($arg[0])) {
Branch: 1 branch
BranchTrueFalseTotal
if (@arg and ref $arg[0]) { } 68 2 70
Condition66%2/3
@arg and ref $arg[0]
!ll&&!rl&&r
0268
MC/DC50%1/2
@arg and ref $arg[0]
@arg ref $arg[0]
Truth table66%2/3
A and B
A= @argB= ref $arg[0]
ABresult
0X0
100
111
35 68 $request = shift @arg;
36 68 ▶ croak 'request(): options must be key/value pairs' if @arg % 2;
Branch: 1 branch
BranchTrueFalseTotal
if @arg % 2 0 68 68
37 68 %option = @arg;
38 } else {
39 2 ▶ croak 'request(): request fields must be key/value pairs' if @arg % 2;
Branch: 1 branch
BranchTrueFalseTotal
if @arg % 2 0 2 2
40 2 my %field = @arg;
41 2 for my $name (qw(
42 stream_body
43 on_informational
44 on_response
45 on_body
46 on_complete
47 on_error
48 on_switch
49 on_drain
50 )) {
51 16 ▶ $option{$name} = delete $field{$name} if exists $field{$name};
Branch: 1 branch
BranchTrueFalseTotal
if exists $field{$name} 3 13 16
52 }
53 2 $request = Uniform::HTTP::Request->new(%field);
54 }
55  
56 70 ▶ croak 'request(): requires a Uniform HTTP request object'
Branch: 1 branch
BranchTrueFalseTotal
unless ref $request and $request->can("method") and $request->can("target") and $request->can("header_count") and $request->can("has_buffered_body") 0 70 70
Condition33%4/12
ref $request and $request->can("method") and $request->can("target") and $request->can("header_count") and $request->can("has_buffered_body")
!ll&&!rl&&r
0070
ref $request and $request->can("method") and $request->can("target") and $request->can("header_count")
!ll&&!rl&&r
0070
ref $request and $request->can("method") and $request->can("target")
!ll&&!rl&&r
0070
ref $request and $request->can("method")
!ll&&!rl&&r
0070
MC/DC0%0/5
ref $request and $request->can("method") and $request->can("target") and $request->can("header_count") and $request->can("has_buffered_body")
ref $request $request->can("method") $request->can("target") $request->can("header_count") $request->can("has_buffered_body")
Truth table16%1/6
A and B and C and D and E
A= ref $requestB= $request->can("method")C= $request->can("target")D= $request->can("header_count")E= $request->can("has_buffered_body")
ABCDEresult
0XXXX0
10XXX0
110XX0
1110X0
111100
111111
57 unless ref($request) && $request->can('method') && $request->can('target')
58 && $request->can('header_count') && $request->can('has_buffered_body');
59  
60 70 ▶ my $stream_body = delete($option{stream_body}) ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
delete $option{'stream_body'} ? : 5 65 70
61 70 my %callbacks;
62 70 for my $name (qw(on_informational on_response on_body on_complete on_error on_switch on_drain)) {
63 490 ▶ next unless exists $option{$name};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $option{$name} 345 145 490
64 145 my $cb = delete $option{$name};
65 145 ▶ croak "request(): $name must be a coderef" unless ref($cb) eq 'CODE';
Branch: 1 branch
BranchTrueFalseTotal
unless ref $cb eq "CODE" 0 145 145
66 145 $callbacks{$name} = $cb;
67 }
68 croak 'request(): on_drain requires stream_body'
69 70 ▶ if $callbacks{on_drain} && !$stream_body;
Branch: 1 branch
BranchTrueFalseTotal
if $callbacks{"on_drain"} and not $stream_body 0 70 70
Condition66%2/3
$callbacks{"on_drain"} and not $stream_body
!ll&&!rl&&r
6910
MC/DC0%0/2
$callbacks{"on_drain"} and not $stream_body
$callbacks{"on_drain"} not $stream_body
Truth table66%2/3
A and not(B)
A= $callbacks{"on_drain"}B= not $stream_body
ABresult
0X0
100
111
70 70 ▶ croak 'request(): unknown options: ' . join(', ', sort keys %option) if %option;
Branch: 1 branch
BranchTrueFalseTotal
if %option 0 70 70
71  
72 70 my $tx = Unblock::HTTP1::Transaction->_new(
73 $self, $request,
74 callbacks => \%callbacks,
75 local_done => 0,
76 );
77 70 $tx->{stream_body} = $stream_body;
78 70 push @{ $self->{queue} }, $tx;
79 70 ▶ $self->_start_next unless $self->{active};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"active"} 65 5 70
80 70 return $tx;
81 }
82  
83 0 ▶sub transaction { $_[0]{active} }
Subroutine transaction: not called CC=1 SCAR=6.9
Pod documented
84  
85 98 ▶sub _start_next {
Subroutine _start_next: called CC=7 SCAR=19.7
86 98 my ($self) = @_;
87 98 ▶ return if $self->{active} || $self->{closed} || $self->{switched};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"active"} or $self->{"closed"} or $self->{"switched"} 0 98 98
Condition33%2/6
$self->{"active"} or $self->{"closed"} or $self->{"switched"}
l!l&&r!l&&!r
0098
$self->{"active"} or $self->{"closed"}
l!l&&r!l&&!r
0098
MC/DC0%0/3
$self->{"active"} or $self->{"closed"} or $self->{"switched"}
$self->{"active"} $self->{"closed"} $self->{"switched"}
Truth table25%1/4
A or B or C
A= $self->{"active"}B= $self->{"closed"}C= $self->{"switched"}
ABCresult
1XX1
01X1
0011
0000
88 98 ▶ my $tx = shift @{ $self->{queue} } or return;
Branch: 1 branch
BranchTrueFalseTotal
my $tx = shift @{$$self{"queue"};} or return 68 30 98
89 68 my $plan;
90 68 my $ok = eval {
91 $plan = Unblock::HTTP1::_Wire::request_plan(
92 $tx->request,
93 stream_body => $tx->{stream_body},
94 68 );
95 64 1;
96 };
97 68 ▶ if (!$ok) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($ok) 4 64 68
98 4 $tx->_fail("$@");
99 4 $tx->_invoke('on_error', "$@");
100 4 return $self->_start_next;
101 }
102 64 $tx->{send_plan} = $plan;
103 64 ▶ $tx->{local_done} = $plan->{body_finalized} ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$plan->{'body_finalized'} ? : 59 5 64
104 64 $self->{active} = $tx;
105 64 $self->_queue_output($plan->{wire});
106 64 return;
107 }
108  
109 2 ▶sub _input_native_head {
Subroutine _input_native_head: called CC=10 SCAR=24.5
110 2 my ($self, $head, $response) = @_;
111 croak '_input_native_head(): cannot be called recursively from an engine callback'
112 2 ▶ if $self->{driving};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"driving"} 0 2 2
113 2 ▶ return (4, 0) if $self->{switched};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"switched"} 0 2 2
114 2 ▶ return (3, 0) if $self->{closed};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"closed"} 0 2 2
115 croak '_input_native_head(): cannot mix native head input with buffered portable input'
116 2 ▶ if length $self->{input};
Branch: 1 branch
BranchTrueFalseTotal
if length $self->{"input"} 0 2 2
117 croak '_input_native_head(): response received with no outstanding request'
118 2 ▶ unless $self->{active};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"active"} 0 2 2
119 croak '_input_native_head(): response body is already active'
120 2 ▶ if $self->{rx};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"rx"} 0 2 2
121  
122 2 my ($status, $ready);
123 {
124 2 local $self->{borrowed_head} = $head;
125 2 local $self->{borrowed_message} = $response;
126 2 local $self->{native_head_preconsumed} = 1;
127 2 local $self->{driving} = 1;
128 2 $self->_drive;
129 2 ▶ $status = $self->{closed} ? 3 : $self->{switched} ? 4 : 0;
Branch: 2 branches
BranchTrueFalseTotal
$self->{'closed'} ? : 0 2 2
$self->{'switched'} ? : 0 2 2
130 2 $ready = $self->_borrowed_native_head_ready;
131 }
132 2 ▶ $self->_transport_sync if $self->{transport_attached};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"transport_attached"} 0 2 2
133 2 return ($status, $ready);
134 }
135  
136 204 ▶sub _drive {
Subroutine _drive: called CC=79 SCAR=46.9
137 204 my ($self) = @_;
138  
139 204 ▶ if (!$self->{closed} && !$self->{switched}
Branch: 1 branch
BranchTrueFalseTotal
if (not $self->{"closed"} || $self->{"switched"} || $self->{"active"} and $self->_input_length) 2 202 204
Condition55%5/9
not $self->{"closed"} || $self->{"switched"} || $self->{"active"} and $self->_input_length
!ll&&!rl&&r
20202
$self->{'closed'} || $self->{'switched'} || $self->{'active'}
l!l&&r!l&&!r
02022
$self->{"closed"} or $self->{"switched"}
l!l&&r!l&&!r
00204
MC/DC25%1/4
not $self->{"closed"} || $self->{"switched"} || $self->{"active"} and $self->_input_length
$self->{"closed"} $self->{"switched"} $self->{'active'} $self->_input_length
Truth table40%2/5
not(A or B || C) and D
A= $self->{"closed"}B= $self->{"switched"}C= $self->{'active'}D= $self->_input_length
ABCDresult
1XXX0
01XX0
001X0
00000
00011
140 && !$self->{active} && $self->_input_length) {
141 2 ▶ if ($self->_input_remaining =~ /\A(?:\r\n)+\z/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->_input_remaining =~ /\A(?:\r\n)+\z/) 1 1 2
142 1 $self->_input_clear;
143 1 return;
144 }
145 1 return $self->_connection_error(
146 'HTTP/1 response bytes received with no outstanding request'
147 );
148 }
149  
150 202 ▶ while (!$self->{closed} && !$self->{switched} && $self->{active}) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $self->{"closed"} || $self->{"switched"} and $self->{"active"}) 214 30 244
Condition83%5/6
not $self->{"closed"} || $self->{"switched"} and $self->{"active"}
!ll&&!rl&&r
426214
$self->{'closed'} || $self->{'switched'}
l!l&&r!l&&!r
40240
MC/DC66%2/3
not $self->{"closed"} || $self->{"switched"} and $self->{"active"}
$self->{'closed'} $self->{'switched'} $self->{"active"}
Truth table75%3/4
not(A || B) and C
A= $self->{'closed'}B= $self->{'switched'}C= $self->{"active"}
ABCresult
1XX0
01X0
0000
0011
151 214 my $tx = $self->{active};
152 214 my $rx = $self->{rx};
153  
154 214 ▶ if (!$rx) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($rx) 171 43 214
155 171 my $head = delete $self->{borrowed_head};
156 171 my $response = delete $self->{borrowed_message};
157 171 ▶ my $native_response = $response ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$response ? : 5 166 171
158 171 ▶ if (!$head) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($head) 166 5 171
159 166 my ($input, $offset) = $self->_input_window;
160 $head = Unblock::HTTP1::_Native->parse_response_head(
161 166 $input, 0, $self->{max_headers}, $offset,
162 );
163 }
164 171 ▶ if (!$head) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($head) 112 59 171
165 return $self->_connection_error('HTTP/1 response head exceeds configured limit')
166 112 ▶ if $self->_input_length > $self->{max_head_size};
Branch: 1 branch
BranchTrueFalseTotal
if $self->_input_length > $self->{"max_head_size"} 0 112 112
167 112 return;
168 }
169 59 ▶ return $self->_connection_error($head->{error}) unless $head->{ok};
Branch: 1 branch
BranchTrueFalseTotal
unless $head->{"ok"} 0 59 59
170 return $self->_connection_error('HTTP/1 response head exceeds configured limit')
171 59 ▶ if $head->{consumed} > $self->{max_head_size};
Branch: 1 branch
BranchTrueFalseTotal
if $head->{"consumed"} > $self->{"max_head_size"} 1 58 59
172 $self->_input_discard($head->{consumed})
173 58 ▶ unless $self->{native_head_preconsumed};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"native_head_preconsumed"} 56 2 58
174  
175 my $informational =
176 $head->{status} >= 100 && $head->{status} < 200
177 58 ▶ && $head->{status} != 101 ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$head->{'status'} >= 100 && $head->{'status'} < 200 && $head->{'status'} != 101 ? : 4 54 58
Condition83%5/6
$head->{"status"} >= 100 and $head->{"status"} < 200 and $head->{"status"} != 101
!ll&&!rl&&r
5044
$head->{"status"} >= 100 and $head->{"status"} < 200
!ll&&!rl&&r
0508
MC/DC66%2/3
$head->{"status"} >= 100 and $head->{"status"} < 200 and $head->{"status"} != 101
$head->{"status"} >= 100 $head->{"status"} < 200 $head->{"status"} != 101
Truth table75%3/4
A and B and C
A= $head->{"status"} >= 100B= $head->{"status"} < 200C= $head->{"status"} != 101
ABCresult
0XX0
10X0
1100
1111
178 58 ▶ if (!$response) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($response) 53 5 58
179 53 $response =
180 Unblock::HTTP1::_Wire::_response_from_validated_head(
181 $head, $informational,
182 );
183 }
184  
185 58 my $plan;
186 58 my $ok = eval {
187 58 ▶ $plan = Unblock::HTTP1::_Wire::response_receive_plan(
Branch: 1 branch
BranchTrueFalseTotal
$native_response ? : 5 53 58
188 $tx->request,
189 $head,
190 $native_response ? $response : undef,
191 );
192 48 1;
193 };
194 58 ▶ return $self->_connection_error("$@") unless $ok;
Branch: 1 branch
BranchTrueFalseTotal
unless $ok 10 48 58
195  
196 48 ▶ if ($informational) {
Branch: 1 branch
BranchTrueFalseTotal
if ($informational) 3 45 48
197 3 my $cb = $tx->_invoke('on_informational', $response);
198 3 ▶ return $self->_connection_error($cb) unless $cb eq '1';
Branch: 1 branch
BranchTrueFalseTotal
unless $cb eq 1 0 3 3
199 3 next;
200 }
201  
202 45 $tx->_set_response($response);
203  
204 my $fixed_ready = !$plan->{switch}
205 && $plan->{mode} eq 'content-length'
206 && defined($plan->{remaining})
207 45 ▶ && $self->_input_length >= $plan->{remaining};
Condition88%8/9
!$plan->{'switch'} && $plan->{'mode'} eq 'content-length' && defined $plan->{'remaining'} && $self->_input_length >= $plan->{'remaining'}
!ll&&!rl&&r
21519
not $plan->{"switch"} and $plan->{"mode"} eq "content-length" and defined $plan->{"remaining"}
!ll&&!rl&&r
21024
not $plan->{"switch"} and $plan->{"mode"} eq "content-length"
!ll&&!rl&&r
41724
MC/DC75%3/4
!$plan->{'switch'} && $plan->{'mode'} eq 'content-length' && defined $plan->{'remaining'} && $self->_input_length >= $plan->{'remaining'}
not $plan->{"switch"} $plan->{"mode"} eq "content-length" defined $plan->{"remaining"} $self->_input_length >= $plan->{'remaining'}
Truth table80%4/5
not(A) and B and C && D
A= not $plan->{"switch"}B= $plan->{"mode"} eq "content-length"C= defined $plan->{"remaining"}D= $self->_input_length >= $plan->{'remaining'}
ABCDresult
0XXX0
10XX0
110X0
11100
11111
208 my $immediate = !$plan->{switch}
209 45 ▶ && ($plan->{mode} eq 'none' || $fixed_ready);
Condition100%6/6
!$plan->{'switch'} && ($plan->{'mode'} eq 'none' || $fixed_ready)
!ll&&!rl&&r
41526
$plan->{"mode"} eq "none" or $fixed_ready
l!l&&r!l&&!r
71915
MC/DC100%3/3
!$plan->{'switch'} && ($plan->{'mode'} eq 'none' || $fixed_ready)
!$plan->{'switch'} $plan->{"mode"} eq "none" $fixed_ready
Truth table100%4/4
not(A) && B or C
A= !$plan->{'switch'}B= $plan->{"mode"} eq "none"C= $fixed_ready
ABCresult
0XX0
1000
11X1
1011
210  
211 45 ▶ if (!$immediate) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($immediate) 19 26 45
212 $self->{rx} = $rx = {
213 response => $response,
214 mode => $plan->{mode},
215 remaining => $plan->{remaining},
216 keep_alive => $plan->{keep_alive},
217 switch => $plan->{switch},
218 19 ▶ forbid_content => $plan->{forbid_content} ? 1 : 0,
Branch: 1 branch
BranchTrueFalseTotal
$plan->{'forbid_content'} ? : 2 17 19
219 };
220 19 ▶ if ($rx->{mode} eq 'chunked') {
Branch: 1 branch
BranchTrueFalseTotal
if ($rx->{"mode"} eq "chunked") 8 11 19
221 8 $rx->{decoder} = Unblock::HTTP1::_Native::Chunked->new($self->{max_chunk_extension_size});
222 }
223 }
224  
225 45 my $cb = $tx->_invoke('on_response', $response);
226 45 ▶ return $self->_connection_error($cb) unless $cb eq '1';
Branch: 1 branch
BranchTrueFalseTotal
unless $cb eq 1 1 44 45
227 44 ▶ return if $self->{closed};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"closed"} 0 44 44
228  
229 44 ▶ if ($plan->{switch}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($plan->{"switch"}) 4 40 44
230 return $self->_connection_error(
231 'protocol switch received before streaming request body completed'
232 4 ▶ ) if $tx->{stream_body} && !$tx->{local_done};
Branch: 1 branch
BranchTrueFalseTotal
if $tx->{"stream_body"} and not $tx->{"local_done"} 0 4 4
Condition33%1/3
$tx->{"stream_body"} and not $tx->{"local_done"}
!ll&&!rl&&r
400
MC/DC0%0/2
$tx->{"stream_body"} and not $tx->{"local_done"}
$tx->{"stream_body"} not $tx->{"local_done"}
Truth table33%1/3
A and not(B)
A= $tx->{"stream_body"}B= not $tx->{"local_done"}
ABresult
0X0
100
111
233 4 $response->mark_complete->freeze;
234 4 $tx->_mark_remote_done;
235 4 $tx->_mark_complete;
236 4 $self->{rx} = undef;
237 4 $self->_mark_switched;
238 4 $self->_fail_queued('HTTP/1 connection switched protocols');
239 4 $self->{active} = undef;
240 4 ▶ if ($self->{transport_attached}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"transport_attached"}) 0 4 4
241 0 $self->{switch_notice} = [ $tx, $response ];
242 0 ▶ $self->_transport_sync if $self->{transport_attached};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"transport_attached"} 0 0 0
243 0 return;
244 }
245 4 return $self->_deliver_switch_notice($tx, $response);
246 }
247  
248 40 ▶ if ($plan->{mode} eq 'none') {
Branch: 1 branch
BranchTrueFalseTotal
if ($plan->{"mode"} eq "none") 7 33 40
249 $self->_complete_response(
250 $tx, $response, $plan->{keep_alive},
251 7 );
252 7 next;
253 }
254  
255 33 ▶ if ($fixed_ready) {
Branch: 1 branch
BranchTrueFalseTotal
if ($fixed_ready) 18 15 33
256 18 my $length = $plan->{remaining};
257 18 ▶ if ($length) {
Branch: 1 branch
BranchTrueFalseTotal
if ($length) 16 2 18
258 16 my $bytes = $self->_input_take($length);
259 return $self->_connection_error(
260 '205 response must not contain content'
261 16 ▶ ) if $plan->{forbid_content} && length $bytes;
Branch: 1 branch
BranchTrueFalseTotal
if $plan->{"forbid_content"} and length $bytes 0 16 16
Condition33%1/3
$plan->{"forbid_content"} and length $bytes
!ll&&!rl&&r
1600
MC/DC0%0/2
$plan->{"forbid_content"} and length $bytes
$plan->{"forbid_content"} length $bytes
Truth table33%1/3
A and B
A= $plan->{"forbid_content"}B= length $bytes
ABresult
0X0
100
111
262 16 my $body_cb = $tx->_invoke('on_body', $response, $bytes);
263 16 ▶ return $self->_connection_error($body_cb)
Branch: 1 branch
BranchTrueFalseTotal
unless $body_cb eq 1 0 16 16
264 unless $body_cb eq '1';
265 16 ▶ return if $self->{closed};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"closed"} 0 16 16
266 }
267 $self->_complete_response(
268 $tx, $response, $plan->{keep_alive},
269 18 );
270 18 next;
271 }
272 }
273  
274 58 ▶ $rx = $self->{rx} or next;
Branch: 1 branch
BranchTrueFalseTotal
$rx = $self->{"rx"} or next 58 0 58
275 58 ▶ if ($rx->{mode} eq 'content-length') {
Branch: 1 branch
BranchTrueFalseTotal
if ($rx->{"mode"} eq "content-length") 9 49 58
276 9 ▶ return unless $self->_input_length;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->_input_length 1 8 9
277 8 my $available = $self->_input_length;
278 my $take = $available < $rx->{remaining}
279 8 ▶ ? $available : $rx->{remaining};
Branch: 1 branch
BranchTrueFalseTotal
$available < $rx->{'remaining'} ? : 5 3 8
280 8 my $bytes = $self->_input_take($take);
281 8 $rx->{remaining} -= $take;
282 return $self->_connection_error('205 response must not contain content')
283 8 ▶ if $rx->{forbid_content} && length $bytes;
Branch: 1 branch
BranchTrueFalseTotal
if $rx->{"forbid_content"} and length $bytes 0 8 8
Condition33%1/3
$rx->{"forbid_content"} and length $bytes
!ll&&!rl&&r
800
MC/DC0%0/2
$rx->{"forbid_content"} and length $bytes
$rx->{"forbid_content"} length $bytes
Truth table33%1/3
A and B
A= $rx->{"forbid_content"}B= length $bytes
ABresult
0X0
100
111
284 8 my $cb = $tx->_invoke('on_body', $rx->{response}, $bytes);
285 8 ▶ return $self->_connection_error($cb) unless $cb eq '1';
Branch: 1 branch
BranchTrueFalseTotal
unless $cb eq 1 0 8 8
286 8 ▶ if ($rx->{remaining} == 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($rx->{"remaining"} == 0) 3 5 8
287 3 $self->_finish_response;
288 3 next;
289 }
290 5 return;
291 }
292  
293 49 ▶ if ($rx->{mode} eq 'chunked') {
Branch: 1 branch
BranchTrueFalseTotal
if ($rx->{"mode"} eq "chunked") 26 23 49
294 26 ▶ return unless $self->_input_length;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->_input_length 1 25 26
295 25 my ($input, $offset) = $self->_input_window;
296 25 my $available = $self->_input_length;
297 25 my ($done, $decoded, $leftover);
298 25 my $ok = eval {
299 ($done, $decoded, $leftover) =
300 25 $rx->{decoder}->feed($input, 1, $offset);
301 25 1;
302 };
303 25 ▶ return $self->_connection_error("$@") unless $ok;
Branch: 1 branch
BranchTrueFalseTotal
unless $ok 0 25 25
304 25 $self->_input_discard($available - length($leftover));
305 25 ▶ if (defined($decoded) && length($decoded)) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $decoded and length $decoded) 11 14 25
Condition66%2/3
defined $decoded and length $decoded
!ll&&!rl&&r
01411
MC/DC50%1/2
defined $decoded and length $decoded
defined $decoded length $decoded
Truth table66%2/3
A and B
A= defined $decodedB= length $decoded
ABresult
0X0
100
111
306 return $self->_connection_error('205 response must not contain content')
307 11 ▶ if $rx->{forbid_content};
Branch: 1 branch
BranchTrueFalseTotal
if $rx->{"forbid_content"} 1 10 11
308 10 my $cb = $tx->_invoke('on_body', $rx->{response}, $decoded);
309 10 ▶ return $self->_connection_error($cb) unless $cb eq '1';
Branch: 1 branch
BranchTrueFalseTotal
unless $cb eq 1 0 10 10
310 }
311 24 ▶ return unless $done;
Branch: 1 branch
BranchTrueFalseTotal
unless $done 18 6 24
312 6 $rx->{mode} = 'trailers';
313 6 delete $rx->{decoder};
314 6 next;
315 }
316  
317 23 ▶ if ($rx->{mode} eq 'trailers') {
Branch: 1 branch
BranchTrueFalseTotal
if ($rx->{"mode"} eq "trailers") 21 2 23
318 21 my ($input, $offset) = $self->_input_window;
319 my $trailers = Unblock::HTTP1::_Native->parse_trailers(
320 21 $input, 0, $self->{max_headers}, $offset,
321 );
322 21 ▶ if (!$trailers) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($trailers) 15 6 21
323 return $self->_connection_error('HTTP/1 trailer section exceeds configured limit')
324 15 ▶ if $self->_input_length > $self->{max_head_size};
Branch: 1 branch
BranchTrueFalseTotal
if $self->_input_length > $self->{"max_head_size"} 0 15 15
325 15 return;
326 }
327 6 ▶ return $self->_connection_error($trailers->{error}) unless $trailers->{ok};
Branch: 1 branch
BranchTrueFalseTotal
unless $trailers->{"ok"} 0 6 6
328 return $self->_connection_error('HTTP/1 trailer section exceeds configured limit')
329 6 ▶ if $trailers->{consumed} > $self->{max_head_size};
Branch: 1 branch
BranchTrueFalseTotal
if $trailers->{"consumed"} > $self->{"max_head_size"} 1 5 6
330 5 for my $field (@{ $trailers->{headers} }) {
331 2 my $name = lc $field->[0];
332 2 ▶ return $self->_connection_error('forbidden framing field in HTTP/1 trailers')
Branch: 1 branch
BranchTrueFalseTotal
if $name eq "content-length" or $name eq "transfer-encoding" or $name eq "host" or $name eq "connection" or $name eq "trailer" 0 2 2
Condition33%4/12
$name eq "content-length" or $name eq "transfer-encoding" or $name eq "host" or $name eq "connection" or $name eq "trailer"
l!l&&r!l&&!r
002
$name eq "content-length" or $name eq "transfer-encoding" or $name eq "host" or $name eq "connection"
l!l&&r!l&&!r
002
$name eq "content-length" or $name eq "transfer-encoding" or $name eq "host"
l!l&&r!l&&!r
002
$name eq "content-length" or $name eq "transfer-encoding"
l!l&&r!l&&!r
002
MC/DC0%0/5
$name eq "content-length" or $name eq "transfer-encoding" or $name eq "host" or $name eq "connection" or $name eq "trailer"
$name eq "content-length" $name eq "transfer-encoding" $name eq "host" $name eq "connection" $name eq "trailer"
Truth table16%1/6
A or B or C or D or E
A= $name eq "content-length"B= $name eq "transfer-encoding"C= $name eq "host"D= $name eq "connection"E= $name eq "trailer"
ABCDEresult
1XXXX1
01XXX1
001XX1
0001X1
000011
000000
333 if $name eq 'content-length' || $name eq 'transfer-encoding'
334 || $name eq 'host' || $name eq 'connection' || $name eq 'trailer';
335 2 $rx->{response}->add_trailer(@$field);
336 }
337 5 $self->_input_discard($trailers->{consumed});
338 5 $self->_finish_response;
339 5 next;
340 }
341  
342 2 ▶ if ($rx->{mode} eq 'close') {
Branch: 1 branch
BranchTrueFalseTotal
if ($rx->{"mode"} eq "close") 2 0 2
343 2 ▶ return unless $self->_input_length;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->_input_length 0 2 2
344 2 my $bytes = $self->_input_take($self->_input_length);
345 return $self->_connection_error('205 response must not contain content')
346 2 ▶ if $rx->{forbid_content} && length $bytes;
Branch: 1 branch
BranchTrueFalseTotal
if $rx->{"forbid_content"} and length $bytes 0 2 2
Condition33%1/3
$rx->{"forbid_content"} and length $bytes
!ll&&!rl&&r
200
MC/DC0%0/2
$rx->{"forbid_content"} and length $bytes
$rx->{"forbid_content"} length $bytes
Truth table33%1/3
A and B
A= $rx->{"forbid_content"}B= length $bytes
ABresult
0X0
100
111
347 2 my $cb = $tx->_invoke('on_body', $rx->{response}, $bytes);
348 2 ▶ return $self->_connection_error($cb) unless $cb eq '1';
Branch: 1 branch
BranchTrueFalseTotal
unless $cb eq 1 0 2 2
349 2 return;
350 }
351  
352 0 return $self->_connection_error('invalid HTTP/1 client receive state');
353 }
354 30 return;
355 }
356  
357 6 ▶sub _borrowed_native_head_ready {
Subroutine _borrowed_native_head_ready: called CC=6 SCAR=18.0
358 6 my ($self) = @_;
359 6 ▶ return 0 if $self->{closed} || $self->{switched};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"closed"} or $self->{"switched"} 1 5 6
Condition66%2/3
$self->{"closed"} or $self->{"switched"}
l!l&&r!l&&!r
015
MC/DC50%1/2
$self->{"closed"} or $self->{"switched"}
$self->{"closed"} $self->{"switched"}
Truth table66%2/3
A or B
A= $self->{"closed"}B= $self->{"switched"}
ABresult
1X1
011
000
360 5 ▶ return 0 unless $self->{active};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"active"} 3 2 5
361 2 ▶ return 0 if $self->{rx};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"rx"} 1 1 2
362 1 ▶ return 0 if length $self->{input};
Branch: 1 branch
BranchTrueFalseTotal
if length $self->{"input"} 0 1 1
363 1 return 1;
364 }
365  
366 10 ▶sub _finish_response {
Subroutine _finish_response: called CC=3 SCAR=11.4
367 10 my ($self) = @_;
368 10 ▶ my $tx = $self->{active} or return;
Branch: 1 branch
BranchTrueFalseTotal
my $tx = $self->{"active"} or return 10 0 10
369 10 ▶ my $rx = delete $self->{rx} or return;
Branch: 1 branch
BranchTrueFalseTotal
my $rx = delete $self->{"rx"} or return 10 0 10
370 return $self->_complete_response(
371 $tx, $rx->{response}, $rx->{keep_alive},
372 10 );
373 }
374  
375 35 ▶sub _complete_response {
Subroutine _complete_response: called CC=4 SCAR=13.9
376 35 my ($self, $tx, $response, $keep_alive) = @_;
377 35 $response->mark_complete->freeze;
378 35 $tx->_mark_remote_done;
379 35 ▶ $tx->{keep_alive} = $keep_alive ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$keep_alive ? : 31 4 35
380  
381 # A final response can arrive before an incremental request body has
382 # finished. The peer has already ended this HTTP exchange, so no further
383 # request-body bytes may be sent and the connection cannot be reused.
384 35 ▶ if ($tx->{stream_body} && !$tx->{local_done}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($tx->{"stream_body"} and not $tx->{"local_done"}) 1 34 35
Condition100%3/3
$tx->{"stream_body"} and not $tx->{"local_done"}
!ll&&!rl&&r
3311
MC/DC100%2/2
$tx->{"stream_body"} and not $tx->{"local_done"}
$tx->{"stream_body"} not $tx->{"local_done"}
Truth table100%3/3
A and not(B)
A= $tx->{"stream_body"}B= not $tx->{"local_done"}
ABresult
0X0
100
111
385 1 $tx->{request_body_cancelled} = 1;
386 1 $tx->_mark_local_done;
387 1 $tx->{keep_alive} = 0;
388 1 $self->{output} = '';
389 }
390  
391 35 $self->_retire_if_done;
392 35 return;
393 }
394  
395 37 ▶sub _retire_if_done {
Subroutine _retire_if_done: called CC=12 SCAR=25.3
396 37 my ($self) = @_;
397 37 ▶ my $tx = $self->{active} or return;
Branch: 1 branch
BranchTrueFalseTotal
my $tx = $self->{"active"} or return 37 0 37
398 37 ▶ return unless $tx->{local_done} && $tx->{remote_done};
Branch: 1 branch
BranchTrueFalseTotal
unless $tx->{"local_done"} and $tx->{"remote_done"} 2 35 37
Condition66%2/3
$tx->{"local_done"} and $tx->{"remote_done"}
!ll&&!rl&&r
0235
MC/DC50%1/2
$tx->{"local_done"} and $tx->{"remote_done"}
$tx->{"local_done"} $tx->{"remote_done"}
Truth table66%2/3
A and B
A= $tx->{"local_done"}B= $tx->{"remote_done"}
ABresult
0X0
100
111
399 35 ▶ $tx->_mark_complete unless $tx->is_terminal;
Branch: 1 branch
BranchTrueFalseTotal
unless $tx->is_terminal 35 0 35
400 35 my $cb = $tx->_invoke('on_complete');
401 35 ▶ return $self->_connection_error($cb) unless $cb eq '1';
Branch: 1 branch
BranchTrueFalseTotal
unless $cb eq 1 0 35 35
402  
403 35 ▶ my $keep = $tx->{keep_alive} && $tx->{send_plan}{keep_alive};
Condition66%2/3
$tx->{'keep_alive'} && $tx->{'send_plan'}{'keep_alive'}
!ll&&!rl&&r
4031
MC/DC50%1/2
$tx->{'keep_alive'} && $tx->{'send_plan'}{'keep_alive'}
$tx->{'keep_alive'} $tx->{'send_plan'}{'keep_alive'}
Truth table66%2/3
A && B
A= $tx->{'keep_alive'}B= $tx->{'send_plan'}{'keep_alive'}
ABresult
0X0
100
111
404 35 ▶ my $extra = $self->_input_length ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$self->_input_length ? : 2 33 35
405 35 $self->{active} = undef;
406  
407 # This client serializes requests and never pipelines them. Therefore,
408 # bytes already received beyond a final response boundary cannot belong to
409 # a later response. Do not retain them for a future request: doing so would
410 # allow an unsolicited response to poison the response queue.
411 35 ▶ if ($extra) {
Branch: 1 branch
BranchTrueFalseTotal
if ($extra) 2 33 35
412 2 $self->_input_clear;
413 2 $self->{closed} = 1;
414 2 $self->_fail_queued('unexpected bytes after final HTTP/1 response');
415 2 ▶ $self->_transport_sync if $self->{transport_attached};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"transport_attached"} 0 2 2
416 2 return;
417 }
418  
419 33 ▶ if (!$keep) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($keep) 4 29 33
420 4 $self->{closed} = 1;
421 4 $self->_fail_queued('HTTP/1 connection is not reusable');
422 4 ▶ $self->_transport_sync if $self->{transport_attached};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"transport_attached"} 0 4 4
423 4 return;
424 }
425 29 $self->_start_next;
426 29 return;
427 }
428  
429 8 ▶sub _transaction_write {
Subroutine _transaction_write: called CC=15 SCAR=29.3
430 8 my ($self, $tx, $bytes, $final) = @_;
431 croak 'write(): Transaction is not active on this HTTP/1 connection'
432 8 ▶ unless $self->{active} && $self->{active} == $tx;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"active"} and $self->{"active"} == $tx 0 8 8
Condition33%1/3
$self->{"active"} and $self->{"active"} == $tx
!ll&&!rl&&r
008
MC/DC0%0/2
$self->{"active"} and $self->{"active"} == $tx
$self->{"active"} $self->{"active"} == $tx
Truth table33%1/3
A and B
A= $self->{"active"}B= $self->{"active"} == $tx
ABresult
0X0
100
111
433 8 my $plan = $tx->{send_plan};
434 8 ▶ croak 'write(): request does not have a streaming body' unless $tx->{stream_body};
Branch: 1 branch
BranchTrueFalseTotal
unless $tx->{"stream_body"} 0 8 8
435 8 ▶ croak 'write(): streaming request body is already complete' if $tx->{local_done};
Branch: 1 branch
BranchTrueFalseTotal
if $tx->{"local_done"} 0 8 8
436 8 $bytes = Unblock::HTTP1::_Wire::_bytes('request body chunk', $bytes);
437  
438 8 ▶ if ($plan->{mode} eq 'chunked') {
Branch: 2 branches
BranchTrueFalseTotal
if ($plan->{'mode'} eq 'chunked') { } 6 2 8
elsif ($plan->{'mode'} eq 'content-length') { } 2 0 2
439 6 $self->_queue_output(Unblock::HTTP1::_Wire::chunk($bytes));
440 6 ▶ if ($final) {
Branch: 1 branch
BranchTrueFalseTotal
if ($final) 2 4 6
441 2 my $trailers = Unblock::HTTP1::_Wire::_fields($tx->request, 'trailer');
442 2 $self->_queue_output(Unblock::HTTP1::_Wire::final_chunk($trailers));
443 2 $tx->_mark_local_done;
444 }
445 } elsif ($plan->{mode} eq 'content-length') {
446 2 my $remaining = $plan->{remaining};
447 2 ▶ croak 'write(): body exceeds declared Content-Length' if length($bytes) > $remaining;
Branch: 1 branch
BranchTrueFalseTotal
if length $bytes > $remaining 1 1 2
448 1 $self->_queue_output($bytes);
449 1 $remaining -= length($bytes);
450 1 $plan->{remaining} = $remaining;
451 1 ▶ croak 'end(): body ended before declared Content-Length' if $final && $remaining;
Branch: 1 branch
BranchTrueFalseTotal
if $final and $remaining 1 0 1
Condition33%1/3
$final and $remaining
!ll&&!rl&&r
001
MC/DC0%0/2
$final and $remaining
$final $remaining
Truth table33%1/3
A and B
A= $finalB= $remaining
ABresult
0X0
100
111
452 0 ▶ $tx->_mark_local_done if $remaining == 0;
Branch: 1 branch
BranchTrueFalseTotal
if $remaining == 0 0 0 0
453 } else {
454 0 croak 'write(): invalid streaming request framing mode';
455 }
456  
457 6 ▶ $self->_retire_if_done if $tx->{local_done};
Branch: 1 branch
BranchTrueFalseTotal
if $tx->{"local_done"} 2 4 6
458 6 ▶ $self->_transport_sync if $self->{transport_attached};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"transport_attached"} 0 6 6
459 6 my $ok = $self->_stream_ok;
460 6 ▶ $tx->{blocked} = 1 unless $ok;
Branch: 1 branch
BranchTrueFalseTotal
unless $ok 1 5 6
461 6 return $ok;
462 }
463  
464 4 ▶sub _deliver_switch_notice {
Subroutine _deliver_switch_notice: called CC=2 SCAR=7.0
465 4 my ($self, $tx, $response) = @_;
466 4 my $result = $tx->_invoke('on_switch', $response);
467 4 ▶ $self->_connection_error($result) unless $result eq '1';
Branch: 1 branch
BranchTrueFalseTotal
unless $result eq 1 0 4 4
468 4 return;
469 }
470  
471 0 ▶sub _transaction_respond { croak 'respond(): client Transactions cannot send responses' }
Subroutine _transaction_respond: not called CC=1 SCAR=6.9
472 0 ▶sub _transaction_informational { croak 'send_informational(): client Transactions cannot send responses' }
Subroutine _transaction_informational: not called CC=1 SCAR=6.9
473  
474 4 ▶sub _transaction_cancel {
Subroutine _transaction_cancel: called CC=5 SCAR=17.1
475 4 my ($self, $tx) = @_;
476 4 ▶ return if $tx->is_terminal;
Branch: 1 branch
BranchTrueFalseTotal
if $tx->is_terminal 0 4 4
477 4 $tx->_mark_cancelled;
478 4 $self->{rx} = undef;
479 4 ▶ $self->{active} = undef if $self->{active} && $self->{active} == $tx;
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"active"} and $self->{"active"} == $tx 4 0 4
Condition33%1/3
$self->{"active"} and $self->{"active"} == $tx
!ll&&!rl&&r
004
MC/DC0%0/2
$self->{"active"} and $self->{"active"} == $tx
$self->{"active"} $self->{"active"} == $tx
Truth table33%1/3
A and B
A= $self->{"active"}B= $self->{"active"} == $tx
ABresult
0X0
100
111
480 4 $self->{closed} = 1;
481 4 $self->_fail_queued('HTTP/1 connection closed after cancellation');
482 $self->_transport_abort('HTTP/1 transaction cancelled')
483 4 ▶ if $self->{transport_attached};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"transport_attached"} 0 4 4
484 4 return;
485 }
486  
487 65 ▶sub _maybe_drain {
Subroutine _maybe_drain: called CC=4 SCAR=14.0
488 65 my ($self) = @_;
489 65 ▶ my $tx = $self->{active} or return;
Branch: 1 branch
BranchTrueFalseTotal
my $tx = $self->{"active"} or return 65 0 65
490 65 ▶ return unless $tx->{blocked};
Branch: 1 branch
BranchTrueFalseTotal
unless $tx->{"blocked"} 64 1 65
491 1 $tx->{blocked} = 0;
492 1 my $cb = $tx->_invoke('on_drain');
493 1 ▶ $self->_connection_error($cb) unless $cb eq '1';
Branch: 1 branch
BranchTrueFalseTotal
unless $cb eq 1 0 1 1
494 1 return;
495 }
496  
497 5 ▶sub _on_eof {
Subroutine _on_eof: called CC=7 SCAR=21.6
498 5 my ($self) = @_;
499 5 ▶ return if $self->{switched};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"switched"} 0 5 5
500 5 my $tx = $self->{active};
501 5 ▶ if (!$tx) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($tx) 0 5 5
502 0 $self->{closed} = 1;
503 0 return;
504 }
505 5 my $rx = $self->{rx};
506 5 ▶ if ($rx && $rx->{mode} eq 'close') {
Branch: 1 branch
BranchTrueFalseTotal
if ($rx and $rx->{"mode"} eq "close") 2 3 5
Condition100%3/3
$rx and $rx->{"mode"} eq "close"
!ll&&!rl&&r
122
MC/DC100%2/2
$rx and $rx->{"mode"} eq "close"
$rx $rx->{"mode"} eq "close"
Truth table100%3/3
A and B
A= $rxB= $rx->{"mode"} eq "close"
ABresult
0X0
100
111
507 2 ▶ if (length $self->{input}) {
Branch: 1 branch
BranchTrueFalseTotal
if (length $self->{"input"}) 0 2 2
508 0 my $bytes = substr($self->{input}, 0, length($self->{input}), '');
509 0 my $cb = $tx->_invoke('on_body', $rx->{response}, $bytes);
510 0 ▶ return $self->_connection_error($cb) unless $cb eq '1';
Branch: 1 branch
BranchTrueFalseTotal
unless $cb eq 1 0 0 0
511 }
512 2 $rx->{keep_alive} = 0;
513 2 $self->_finish_response;
514 2 $self->{closed} = 1;
515 2 return;
516 }
517 3 $self->_connection_error('unexpected EOF in HTTP/1 response');
518 3 return;
519 }
520  
521 18 ▶sub _connection_error {
Subroutine _connection_error: called CC=6 SCAR=18.4
522 18 my ($self, $error) = @_;
523 18 ▶ $error = 'HTTP/1 client protocol error' unless defined($error) && length($error);
Branch: 1 branch
BranchTrueFalseTotal
unless defined $error and length $error 0 18 18
Condition33%1/3
defined $error and length $error
!ll&&!rl&&r
0018
MC/DC0%0/2
defined $error and length $error
defined $error length $error
Truth table33%1/3
A and B
A= defined $errorB= length $error
ABresult
0X0
100
111
524 18 my $tx = $self->{active};
525 18 ▶ if ($tx && !$tx->is_terminal) {
Branch: 1 branch
BranchTrueFalseTotal
if ($tx and not $tx->is_terminal) 17 1 18
Condition66%2/3
$tx and not $tx->is_terminal
!ll&&!rl&&r
1017
MC/DC50%1/2
$tx and not $tx->is_terminal
$tx not $tx->is_terminal
Truth table66%2/3
A and not(B)
A= $txB= not $tx->is_terminal
ABresult
0X0
100
111
526 17 $tx->_fail($error);
527 17 eval { $tx->_invoke('on_error', $error) };
528 }
529 18 $self->{active} = undef;
530 18 $self->{rx} = undef;
531 18 $self->{closed} = 1;
532 18 $self->_fail_queued($error);
533 18 ▶ $self->_transport_abort($error) if $self->{transport_attached};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"transport_attached"} 0 18 18
534 18 return;
535 }
536  
537 32 ▶sub _fail_queued {
Subroutine _fail_queued: called CC=4 SCAR=14.0
538 32 my ($self, $error) = @_;
539 32 ▶ for my $tx (@{ delete($self->{queue}) || [] }) {
Condition50%1/2
delete $self->{'queue'} || []
l!l
320
MC/DC0%0/1
delete $self->{'queue'} || []
delete $self->{'queue'}
Truth table50%1/2
A
A= delete $self->{'queue'}
Aresult
11
00
540 2 ▶ next if $tx->is_terminal;
Branch: 1 branch
BranchTrueFalseTotal
if $tx->is_terminal 0 2 2
541 2 $tx->_fail($error);
542 2 eval { $tx->_invoke('on_error', $error) };
543 }
544 32 $self->{queue} = [];
545 32 return;
546 }
547  
548 0 ▶sub _fail_all {
Subroutine _fail_all: not called CC=3 SCAR=24.8
549 0 my ($self, $error) = @_;
550 0 ▶ if (my $tx = delete $self->{active}) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $tx = delete $self->{"active"}) 0 0 0
551 0 ▶ if (!$tx->is_terminal) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($tx->is_terminal) 0 0 0
552 0 $tx->_fail($error);
553 0 eval { $tx->_invoke('on_error', $error) };
554 }
555 }
556 0 $self->{rx} = undef;
557 0 $self->_fail_queued($error);
558 0 return;
559 }
560  
561 27 1;
562  
563 __END__
« blib/lib/Unblock/HTTP1/_Wire.pm ↑ Summary blib/lib/Unblock/HTTP1/Server.pm »