blib/lib/Unblock/HTTP1/Client.pm

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