blib/lib/Unblock/HTTP1/Server.pm

filter: Statementstmt 90.0% 318 / 353 Branchbran 70.6% 188 / 266 Conditioncond 49.1% 61 / 124 MC/DCmcdc 26.0% 19 / 73 Subroutinesub 93.1% 27 / 29 Podpod 100% 2 / 2 totaltotal 72.6% 615 / 847 CC 178 SCAR 35.4
CC
178
Cov
76%
_drive
79.6
_transaction_write
37.8
_transaction_cancel
30.0
CRAP 34.6
« blib/lib/Unblock/HTTP1/Client.pm ↑ Summary blib/lib/Unblock/HTTP1/_Engine.pm »
1 package Unblock::HTTP1::Server;
2  
3 22 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 22 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 22 ▶use Carp qw(croak);
Subroutine BEGIN: called CC=1 SCAR=0.0
6 22 ▶use parent 'Unblock::HTTP1::_Engine';
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 22 ▶use Uniform::HTTP::Request;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 22 ▶use Uniform::HTTP::Response;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 22 ▶use Unblock::HTTP1::_Native ();
Subroutine BEGIN: called CC=1 SCAR=0.0
11 22 ▶use Unblock::HTTP1::_Wire ();
Subroutine BEGIN: called CC=1 SCAR=0.0
12 22 ▶use Unblock::HTTP1::Transaction;
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 22 our $VERSION = '0.11';
15  
16 56 ▶sub new {
Subroutine new: called CC=5 SCAR=16.2
Pod documented
17 56 my ($class, %option) = @_;
18 56 my %callbacks;
19 56 for my $name (qw(on_request on_body on_request_end on_error on_switch)) {
20 280 ▶ next unless exists $option{$name};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $option{$name} 190 90 280
21 90 my $cb = delete $option{$name};
22 90 ▶ croak "new(): $name must be a coderef" unless ref($cb) eq 'CODE';
Branch: 1 branch
BranchTrueFalseTotal
unless ref $cb eq "CODE" 0 90 90
23 90 $callbacks{$name} = $cb;
24 }
25 56 ▶ croak 'new(): on_request callback is required' unless $callbacks{on_request};
Branch: 1 branch
BranchTrueFalseTotal
unless $callbacks{"on_request"} 0 56 56
26 56 my $self = bless {
27 callbacks => \%callbacks,
28 active => undef,
29 rx => undef,
30 }, $class;
31 56 $self->_init_engine(%option);
32 55 return $self;
33 }
34  
35 1 ▶sub transaction { $_[0]{active} }
Subroutine transaction: called CC=1 SCAR=0.0
Pod documented
36  
37 4 ▶sub _input_native_head {
Subroutine _input_native_head: called CC=10 SCAR=24.5
38 4 my ($self, $head, $request) = @_;
39 croak '_input_native_head(): cannot be called recursively from an engine callback'
40 4 ▶ if $self->{driving};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"driving"} 0 4 4
41 4 ▶ return (4, 0) if $self->{switched};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"switched"} 0 4 4
42 4 ▶ return (3, 0) if $self->{closed};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"closed"} 0 4 4
43 croak '_input_native_head(): cannot mix native head input with buffered portable input'
44 4 ▶ if length $self->{input};
Branch: 1 branch
BranchTrueFalseTotal
if length $self->{"input"} 0 4 4
45 croak '_input_native_head(): request body is already active'
46 4 ▶ if $self->{active} || $self->{rx};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"active"} or $self->{"rx"} 0 4 4
Condition33%1/3
$self->{"active"} or $self->{"rx"}
l!l&&r!l&&!r
004
MC/DC0%0/2
$self->{"active"} or $self->{"rx"}
$self->{"active"} $self->{"rx"}
Truth table33%1/3
A or B
A= $self->{"active"}B= $self->{"rx"}
ABresult
1X1
011
000
47  
48 4 my ($status, $ready);
49 {
50 4 local $self->{borrowed_head} = $head;
51 4 local $self->{borrowed_message} = $request;
52 4 local $self->{native_head_preconsumed} = 1;
53 4 local $self->{driving} = 1;
54 4 $self->_drive;
55 4 ▶ $status = $self->{closed} ? 3 : $self->{switched} ? 4 : 0;
Branch: 2 branches
BranchTrueFalseTotal
$self->{'closed'} ? : 0 4 4
$self->{'switched'} ? : 0 4 4
56 4 $ready = $self->_borrowed_native_head_ready;
57 }
58 4 ▶ $self->_transport_sync if $self->{transport_attached};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"transport_attached"} 1 3 4
59 4 return ($status, $ready);
60 }
61  
62 265 ▶sub _drive {
Subroutine _drive: called CC=62 SCAR=43.8
63 265 my ($self) = @_;
64 265 ▶ while (!$self->{closed} && !$self->{switched}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"closed"} or $self->{"switched"}) 304 17 321
Condition100%3/3
$self->{"closed"} or $self->{"switched"}
l!l&&r!l&&!r
107304
MC/DC100%2/2
$self->{"closed"} or $self->{"switched"}
$self->{"closed"} $self->{"switched"}
Truth table100%3/3
A or B
A= $self->{"closed"}B= $self->{"switched"}
ABresult
1X1
011
000
65 304 my $tx = $self->{active};
66 304 my $rx = $self->{rx};
67  
68 304 ▶ if (!$tx) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($tx) 253 51 304
69 253 ▶ return unless $self->{borrowed_head} || $self->_input_length;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"borrowed_head"} or $self->_input_length 23 230 253
Condition100%3/3
$self->{"borrowed_head"} or $self->_input_length
l!l&&r!l&&!r
822223
MC/DC100%2/2
$self->{"borrowed_head"} or $self->_input_length
$self->{"borrowed_head"} $self->_input_length
Truth table100%3/3
A or B
A= $self->{"borrowed_head"}B= $self->_input_length
ABresult
1X1
011
000
70 230 my $head = delete $self->{borrowed_head};
71 230 my $request = delete $self->{borrowed_message};
72 230 ▶ if (!$head) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($head) 222 8 230
73 222 my ($input, $offset) = $self->_input_window;
74 $head = Unblock::HTTP1::_Native->parse_request_head(
75 222 $input, 0, $self->{max_headers}, $offset,
76 );
77 }
78 230 ▶ if (!$head) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($head) 169 61 230
79 169 ▶ if ($self->_input_length > $self->{max_head_size}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->_input_length > $self->{"max_head_size"}) 0 169 169
80 0 $self->_protocol_error(431, 'request head exceeds configured limit');
81 }
82 169 return;
83 }
84 61 ▶ if (!$head->{ok}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($head->{"ok"}) 2 59 61
85 2 ▶ $self->_protocol_error($head->{status} || 400, $head->{error});
Condition50%1/2
$head->{'status'} || 400
l!l
20
MC/DC0%0/1
$head->{'status'} || 400
$head->{'status'}
Truth table50%1/2
A
A= $head->{'status'}
Aresult
11
00
86 2 return;
87 }
88 59 ▶ if ($head->{consumed} > $self->{max_head_size}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($head->{"consumed"} > $self->{"max_head_size"}) 1 58 59
89 1 $self->_protocol_error(431, 'request head exceeds configured limit');
90 1 return;
91 }
92 $self->_input_discard($head->{consumed})
93 58 ▶ unless $self->{native_head_preconsumed};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"native_head_preconsumed"} 54 4 58
94  
95 58 ▶ if ($head->{expect_continue} < 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($head->{"expect_continue"} < 0) 1 57 58
96 1 $self->_protocol_error(417, 'unsupported Expect field');
97 1 return;
98 }
99  
100 57 ▶ if (!$request) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($request) 49 8 57
101 my %target_metadata = Unblock::HTTP1::_Wire::_received_request_metadata(
102 $head->{method}, $head->{target},
103 49 );
104 49 $request = Unblock::HTTP1::_Wire::_request_from_validated_head(
105 $head, %target_metadata,
106 );
107 }
108  
109 57 $tx = Unblock::HTTP1::Transaction->_new(
110 $self, $request,
111 callbacks => {},
112 local_done => 0,
113 remote_done => 0,
114 );
115 57 ▶ $tx->{request_keep_alive} = $head->{keep_alive} ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$head->{'keep_alive'} ? : 47 10 57
116 57 $tx->{request_body_mode} = $head->{body_mode};
117 57 $self->{active} = $tx;
118  
119 57 ▶ my $bodyless = $head->{body_mode} eq 'none' ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$head->{'body_mode'} eq 'none' ? : 43 14 57
120 my $fixed_ready = !$bodyless
121 && $head->{body_mode} eq 'content-length'
122 && defined($head->{content_length})
123 57 ▶ && $self->_input_length >= $head->{content_length};
Condition88%8/9
!$bodyless && $head->{'body_mode'} eq 'content-length' && defined $head->{'content_length'} && $self->_input_length >= $head->{'content_length'}
!ll&&!rl&&r
4944
not $bodyless and $head->{"body_mode"} eq "content-length" and defined $head->{"content_length"}
!ll&&!rl&&r
4908
not $bodyless and $head->{"body_mode"} eq "content-length"
!ll&&!rl&&r
4368
MC/DC75%3/4
!$bodyless && $head->{'body_mode'} eq 'content-length' && defined $head->{'content_length'} && $self->_input_length >= $head->{'content_length'}
not $bodyless $head->{"body_mode"} eq "content-length" defined $head->{"content_length"} $self->_input_length >= $head->{'content_length'}
Truth table80%4/5
not(A) and B and C && D
A= not $bodylessB= $head->{"body_mode"} eq "content-length"C= defined $head->{"content_length"}D= $self->_input_length >= $head->{'content_length'}
ABCDresult
0XXX0
10XX0
110X0
11100
11111
124  
125 57 ▶ if (!$bodyless && !$fixed_ready) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($bodyless or $fixed_ready) 10 47 57
Condition100%3/3
$bodyless or $fixed_ready
l!l&&r!l&&!r
43410
MC/DC100%2/2
$bodyless or $fixed_ready
$bodyless $fixed_ready
Truth table100%3/3
A or B
A= $bodylessB= $fixed_ready
ABresult
1X1
011
000
126 $self->{rx} = $rx = {
127 mode => $head->{body_mode},
128 remaining => $head->{content_length},
129 10 request => $request,
130 };
131 10 ▶ if ($rx->{mode} eq 'chunked') {
Branch: 1 branch
BranchTrueFalseTotal
if ($rx->{"mode"} eq "chunked") 6 4 10
132 6 $rx->{decoder} = Unblock::HTTP1::_Native::Chunked->new($self->{max_chunk_extension_size});
133 }
134 }
135  
136 57 ▶ if ($head->{expect_continue} > 0
Branch: 1 branch
BranchTrueFalseTotal
if ($head->{"expect_continue"} > 0 and $head->{"body_mode"} eq "chunked" || $head->{"body_mode"} eq "content-length" && $head->{"content_length"}) 1 56 57
Condition44%4/9
$head->{"expect_continue"} > 0 and $head->{"body_mode"} eq "chunked" || $head->{"body_mode"} eq "content-length" && $head->{"content_length"}
!ll&&!rl&&r
5601
$head->{"body_mode"} eq "chunked" or $head->{"body_mode"} eq "content-length" and $head->{"content_length"}
l!l&&r!l&&!r
010
$head->{"body_mode"} eq "content-length" and $head->{"content_length"}
!ll&&!rl&&r
001
MC/DC25%1/4
$head->{"expect_continue"} > 0 and $head->{"body_mode"} eq "chunked" || $head->{"body_mode"} eq "content-length" && $head->{"content_length"}
$head->{"expect_continue"} > 0 $head->{"body_mode"} eq "chunked" $head->{"body_mode"} eq "content-length" $head->{"content_length"}
Truth table40%2/5
A and B or C and D
A= $head->{"expect_continue"} > 0B= $head->{"body_mode"} eq "chunked"C= $head->{"body_mode"} eq "content-length"D= $head->{"content_length"}
ABCDresult
0XXX0
100X0
10100
11XX1
10111
137 && ($head->{body_mode} eq 'chunked'
138 || ($head->{body_mode} eq 'content-length'
139 && $head->{content_length}))) {
140 1 $self->_queue_output("HTTP/1.1 100 Continue\r\n\r\n");
141 }
142  
143 57 my $cb = $self->_invoke_server('on_request', $tx, $request);
144 57 ▶ return $self->_application_error($cb) unless $cb eq '1';
Branch: 1 branch
BranchTrueFalseTotal
unless $cb eq 1 5 52 57
145 52 ▶ return if $self->{switched} || $self->{closed};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"switched"} or $self->{"closed"} 0 52 52
Condition33%1/3
$self->{"switched"} or $self->{"closed"}
l!l&&r!l&&!r
0052
MC/DC0%0/2
$self->{"switched"} or $self->{"closed"}
$self->{"switched"} $self->{"closed"}
Truth table33%1/3
A or B
A= $self->{"switched"}B= $self->{"closed"}
ABresult
1X1
011
000
146  
147 52 ▶ if ($bodyless) {
Branch: 1 branch
BranchTrueFalseTotal
if ($bodyless) 39 13 52
148 39 $tx->_mark_remote_done;
149 39 my $end_cb = $self->_invoke_server('on_request_end', $tx, $request);
150 39 ▶ return $self->_application_error($end_cb) unless $end_cb eq '1';
Branch: 1 branch
BranchTrueFalseTotal
unless $end_cb eq 1 0 39 39
151 39 $self->_retire_if_done;
152 39 next;
153 }
154  
155 13 ▶ if ($fixed_ready) {
Branch: 1 branch
BranchTrueFalseTotal
if ($fixed_ready) 3 10 13
156 3 my $length = $head->{content_length};
157 3 ▶ if ($length) {
Branch: 1 branch
BranchTrueFalseTotal
if ($length) 2 1 3
158 2 my $bytes = $self->_input_take($length);
159 2 my $body_cb = $self->_invoke_server(
160 'on_body', $tx, $request, $bytes,
161 );
162 2 ▶ return $self->_application_error($body_cb)
Branch: 1 branch
BranchTrueFalseTotal
unless $body_cb eq 1 0 2 2
163 unless $body_cb eq '1';
164 2 ▶ return if $self->{switched} || $self->{closed};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"switched"} or $self->{"closed"} 0 2 2
Condition33%1/3
$self->{"switched"} or $self->{"closed"}
l!l&&r!l&&!r
002
MC/DC0%0/2
$self->{"switched"} or $self->{"closed"}
$self->{"switched"} $self->{"closed"}
Truth table33%1/3
A or B
A= $self->{"switched"}B= $self->{"closed"}
ABresult
1X1
011
000
165 }
166 3 $self->_complete_request($tx, $request);
167 3 next;
168 }
169 }
170  
171 61 ▶ $tx = $self->{active} or next;
Branch: 1 branch
BranchTrueFalseTotal
$tx = $self->{"active"} or next 61 0 61
172 61 $rx = $self->{rx};
173 61 ▶ return unless $rx;
Branch: 1 branch
BranchTrueFalseTotal
unless $rx 7 54 61
174  
175 54 ▶ if ($rx->{mode} eq 'content-length') {
Branch: 1 branch
BranchTrueFalseTotal
if ($rx->{"mode"} eq "content-length") 8 46 54
176 8 ▶ return unless $self->_input_length;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->_input_length 2 6 8
177 6 my $available = $self->_input_length;
178 my $take = $available < $rx->{remaining}
179 6 ▶ ? $available : $rx->{remaining};
Branch: 1 branch
BranchTrueFalseTotal
$available < $rx->{'remaining'} ? : 2 4 6
180 6 my $bytes = $self->_input_take($take);
181 6 $rx->{remaining} -= $take;
182 6 my $cb = $self->_invoke_server('on_body', $tx, $rx->{request}, $bytes);
183 6 ▶ return $self->_application_error($cb) unless $cb eq '1';
Branch: 1 branch
BranchTrueFalseTotal
unless $cb eq 1 0 6 6
184 6 ▶ if ($rx->{remaining} == 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($rx->{"remaining"} == 0) 4 2 6
185 4 $self->_finish_request;
186 4 next;
187 }
188 2 return;
189 }
190  
191 46 ▶ if ($rx->{mode} eq 'chunked') {
Branch: 1 branch
BranchTrueFalseTotal
if ($rx->{"mode"} eq "chunked") 27 19 46
192 27 ▶ return unless $self->_input_length;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->_input_length 2 25 27
193 25 my ($input, $offset) = $self->_input_window;
194 25 my $available = $self->_input_length;
195 25 my ($done, $decoded, $leftover);
196 25 my $ok = eval {
197 ($done, $decoded, $leftover) =
198 25 $rx->{decoder}->feed($input, 1, $offset);
199 24 1;
200 };
201 25 ▶ if (!$ok) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($ok) 1 24 25
202 1 $self->_protocol_error(400, "$@");
203 1 return;
204 }
205 24 $self->_input_discard($available - length($leftover));
206 24 ▶ if (defined($decoded) && length($decoded)) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $decoded and length $decoded) 11 13 24
Condition66%2/3
defined $decoded and length $decoded
!ll&&!rl&&r
01311
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
207 11 my $cb = $self->_invoke_server('on_body', $tx, $rx->{request}, $decoded);
208 11 ▶ return $self->_application_error($cb) unless $cb eq '1';
Branch: 1 branch
BranchTrueFalseTotal
unless $cb eq 1 0 11 11
209 }
210 24 ▶ return unless $done;
Branch: 1 branch
BranchTrueFalseTotal
unless $done 19 5 24
211 5 $rx->{mode} = 'trailers';
212 5 delete $rx->{decoder};
213 5 next;
214 }
215  
216 19 ▶ if ($rx->{mode} eq 'trailers') {
Branch: 1 branch
BranchTrueFalseTotal
if ($rx->{"mode"} eq "trailers") 19 0 19
217 19 my ($input, $offset) = $self->_input_window;
218 my $trailers = Unblock::HTTP1::_Native->parse_trailers(
219 19 $input, 0, $self->{max_headers}, $offset,
220 );
221 19 ▶ if (!$trailers) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($trailers) 14 5 19
222 14 ▶ if ($self->_input_length > $self->{max_head_size}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->_input_length > $self->{"max_head_size"}) 0 14 14
223 0 $self->_protocol_error(431, 'trailer section exceeds configured limit');
224 }
225 14 return;
226 }
227 5 ▶ if (!$trailers->{ok}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($trailers->{"ok"}) 0 5 5
228 0 $self->_protocol_error(400, $trailers->{error});
229 0 return;
230 }
231 5 ▶ if ($trailers->{consumed} > $self->{max_head_size}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($trailers->{"consumed"} > $self->{"max_head_size"}) 0 5 5
232 0 $self->_protocol_error(431, 'trailer section exceeds configured limit');
233 0 return;
234 }
235 5 for my $field (@{ $trailers->{headers} }) {
236 2 my $name = lc $field->[0];
237 2 ▶ if ($name eq 'content-length' || $name eq 'transfer-encoding'
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
238 || $name eq 'host' || $name eq 'connection' || $name eq 'trailer') {
239 0 $self->_protocol_error(400, 'forbidden framing field in HTTP/1 trailers');
240 0 return;
241 }
242 2 $rx->{request}->add_trailer(@$field);
243 }
244 5 $self->_input_discard($trailers->{consumed});
245 5 $self->_finish_request;
246 5 next;
247 }
248  
249 0 return $self->_protocol_error(400, 'invalid HTTP/1 server receive state');
250 }
251 17 return;
252 }
253  
254 9 ▶sub _finish_request {
Subroutine _finish_request: called CC=3 SCAR=11.4
255 9 my ($self) = @_;
256 9 ▶ my $tx = $self->{active} or return;
Branch: 1 branch
BranchTrueFalseTotal
my $tx = $self->{"active"} or return 9 0 9
257 9 ▶ my $rx = delete $self->{rx} or return;
Branch: 1 branch
BranchTrueFalseTotal
my $rx = delete $self->{"rx"} or return 9 0 9
258 9 return $self->_complete_request($tx, $rx->{request});
259 }
260  
261 12 ▶sub _complete_request {
Subroutine _complete_request: called CC=2 SCAR=7.0
262 12 my ($self, $tx, $request) = @_;
263 12 $request->mark_complete->freeze;
264 12 $tx->_mark_remote_done;
265 12 my $cb = $self->_invoke_server('on_request_end', $tx, $request);
266 12 ▶ return $self->_application_error($cb) unless $cb eq '1';
Branch: 1 branch
BranchTrueFalseTotal
unless $cb eq 1 0 12 12
267 12 $self->_retire_if_done;
268 12 return;
269 }
270  
271 60 ▶sub _transaction_respond {
Subroutine _transaction_respond: called CC=17 SCAR=28.8
272 60 my ($self, $tx, $response, %option) = @_;
273 croak 'respond(): Transaction is not active on this HTTP/1 connection'
274 60 ▶ unless $self->{active} && $self->{active} == $tx;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"active"} and $self->{"active"} == $tx 0 60 60
Condition33%1/3
$self->{"active"} and $self->{"active"} == $tx
!ll&&!rl&&r
0060
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
275 60 ▶ croak 'respond(): Transaction already has a Response' if $tx->response;
Branch: 1 branch
BranchTrueFalseTotal
if $tx->response 0 60 60
276 60 my $status = Unblock::HTTP1::_Wire::_status_code($response->status);
277 60 ▶ croak 'respond(): informational status must use send_informational()'
Branch: 1 branch
BranchTrueFalseTotal
if $status < 200 and $status != 101 1 59 60
Condition100%3/3
$status < 200 and $status != 101
!ll&&!rl&&r
5091
MC/DC100%2/2
$status < 200 and $status != 101
$status < 200 $status != 101
Truth table100%3/3
A and B
A= $status < 200B= $status != 101
ABresult
0X0
100
111
278 if $status < 200 && $status != 101;
279  
280 59 ▶ my $stream_body = delete($option{stream_body}) ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
delete $option{'stream_body'} ? : 4 55 59
281 59 my $on_drain = delete $option{on_drain};
282 59 ▶ croak 'respond(): on_drain must be a coderef'
Branch: 1 branch
BranchTrueFalseTotal
if defined $on_drain and ref $on_drain ne "CODE" 0 59 59
Condition66%2/3
defined $on_drain and ref $on_drain ne "CODE"
!ll&&!rl&&r
5720
MC/DC0%0/2
defined $on_drain and ref $on_drain ne "CODE"
defined $on_drain ref $on_drain ne "CODE"
Truth table66%2/3
A and B
A= defined $on_drainB= ref $on_drain ne "CODE"
ABresult
0X0
100
111
283 if defined($on_drain) && ref($on_drain) ne 'CODE';
284 59 ▶ croak 'respond(): on_drain requires stream_body' if $on_drain && !$stream_body;
Branch: 1 branch
BranchTrueFalseTotal
if $on_drain and not $stream_body 0 59 59
Condition66%2/3
$on_drain and not $stream_body
!ll&&!rl&&r
5720
MC/DC0%0/2
$on_drain and not $stream_body
$on_drain not $stream_body
Truth table66%2/3
A and not(B)
A= $on_drainB= not $stream_body
ABresult
0X0
100
111
285 59 ▶ croak 'respond(): unknown options: ' . join(', ', sort keys %option) if %option;
Branch: 1 branch
BranchTrueFalseTotal
if %option 0 59 59
286  
287 59 my $plan = Unblock::HTTP1::_Wire::response_plan(
288 $tx->request, $response,
289 stream_body => $stream_body,
290 );
291 55 $tx->_set_response($response);
292 55 $tx->{send_plan} = $plan;
293 55 $tx->{stream_body} = $stream_body;
294 55 ▶ $tx->{callbacks}{on_drain} = $on_drain if $on_drain;
Branch: 1 branch
BranchTrueFalseTotal
if $on_drain 2 53 55
295 55 $self->_queue_output($plan->{wire});
296  
297 55 ▶ if ($plan->{switch}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($plan->{"switch"}) 8 47 55
298 8 $tx->_mark_local_done;
299 8 $tx->{switch_pending} = 1;
300 8 $self->_retire_if_done;
301 8 return $tx;
302 }
303  
304 47 ▶ if ($plan->{body_finalized}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($plan->{"body_finalized"}) 43 4 47
305 43 $tx->_mark_local_done;
306 43 ▶ $tx->{keep_alive} = $plan->{keep_alive} ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$plan->{'keep_alive'} ? : 33 10 43
307 43 $self->_retire_if_done;
308 }
309 47 ▶ $self->_transport_sync if $self->{transport_attached};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"transport_attached"} 13 34 47
310 47 return $tx;
311 }
312  
313 4 ▶sub _transaction_informational {
Subroutine _transaction_informational: called CC=8 SCAR=24.0
314 4 my ($self, $tx, $response) = @_;
315 croak 'send_informational(): Transaction is not active on this HTTP/1 connection'
316 4 ▶ unless $self->{active} && $self->{active} == $tx;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"active"} and $self->{"active"} == $tx 0 4 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
317 4 my $status = $response->status;
318 4 ▶ croak 'send_informational(): status must be 100 through 199 except 101'
Branch: 1 branch
BranchTrueFalseTotal
unless $status >= 100 and $status < 200 and $status != 101 0 4 4
Condition33%2/6
$status >= 100 and $status < 200 and $status != 101
!ll&&!rl&&r
004
$status >= 100 and $status < 200
!ll&&!rl&&r
004
MC/DC0%0/3
$status >= 100 and $status < 200 and $status != 101
$status >= 100 $status < 200 $status != 101
Truth table25%1/4
A and B and C
A= $status >= 100B= $status < 200C= $status != 101
ABCresult
0XX0
10X0
1100
1111
319 unless $status >= 100 && $status < 200 && $status != 101;
320 4 ▶ croak 'send_informational(): HTTP/1.0 clients cannot receive 1xx responses'
Branch: 1 branch
BranchTrueFalseTotal
if ($tx->request->version || "1.1") eq "1.0" 1 3 4
Condition50%1/2
$tx->request->version || '1.1'
l!l
40
MC/DC0%0/1
$tx->request->version || '1.1'
$tx->request->version
Truth table50%1/2
A
A= $tx->request->version
Aresult
11
00
321 if ($tx->request->version || '1.1') eq '1.0';
322 3 my $plan = Unblock::HTTP1::_Wire::response_plan($tx->request, $response);
323 3 $self->_queue_output($plan->{wire});
324 3 return $tx;
325 }
326  
327 9 ▶sub _transaction_write {
Subroutine _transaction_write: called CC=19 SCAR=36.3
328 9 my ($self, $tx, $bytes, $final) = @_;
329 croak 'write(): Transaction is not active on this HTTP/1 connection'
330 9 ▶ unless $self->{active} && $self->{active} == $tx;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"active"} and $self->{"active"} == $tx 0 9 9
Condition33%1/3
$self->{"active"} and $self->{"active"} == $tx
!ll&&!rl&&r
009
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
331 9 ▶ my $plan = $tx->{send_plan} or croak 'write(): respond() has not started a response';
Branch: 1 branch
BranchTrueFalseTotal
my $plan = $tx->{"send_plan"} or croak("write(): respond() has not started a response") 9 0 9
332 9 ▶ croak 'write(): response does not have a streaming body' unless $tx->{stream_body};
Branch: 1 branch
BranchTrueFalseTotal
unless $tx->{"stream_body"} 0 9 9
333 9 ▶ croak 'write(): streaming response body is already complete' if $tx->{local_done};
Branch: 1 branch
BranchTrueFalseTotal
if $tx->{"local_done"} 0 9 9
334 9 $bytes = Unblock::HTTP1::_Wire::_bytes('response body chunk', $bytes);
335  
336 9 ▶ if ($plan->{mode} eq 'chunked') {
Branch: 3 branches
BranchTrueFalseTotal
if ($plan->{'mode'} eq 'chunked') { } 7 2 9
elsif ($plan->{'mode'} eq 'content-length') { } 0 2 2
elsif ($plan->{'mode'} eq 'close') { } 2 0 2
337 7 $self->_queue_output(Unblock::HTTP1::_Wire::chunk($bytes));
338 7 ▶ if ($final) {
Branch: 1 branch
BranchTrueFalseTotal
if ($final) 3 4 7
339 3 my $trailers = Unblock::HTTP1::_Wire::_fields($tx->response, 'trailer');
340 3 $self->_queue_output(Unblock::HTTP1::_Wire::final_chunk($trailers));
341 3 $tx->_mark_local_done;
342 }
343 } elsif ($plan->{mode} eq 'content-length') {
344 0 my $remaining = $plan->{remaining};
345 0 ▶ croak 'write(): body exceeds declared Content-Length' if length($bytes) > $remaining;
Branch: 1 branch
BranchTrueFalseTotal
if length $bytes > $remaining 0 0 0
346 0 $self->_queue_output($bytes);
347 0 $remaining -= length($bytes);
348 0 $plan->{remaining} = $remaining;
349 0 ▶ croak 'end(): body ended before declared Content-Length' if $final && $remaining;
Branch: 1 branch
BranchTrueFalseTotal
if $final and $remaining 0 0 0
Condition0%0/3
$final and $remaining
!ll&&!rl&&r
000
MC/DC0%0/2
$final and $remaining
$final $remaining
Truth table0%0/3
A and B
A= $finalB= $remaining
ABresult
0X0
100
111
350 0 ▶ $tx->_mark_local_done if $remaining == 0;
Branch: 1 branch
BranchTrueFalseTotal
if $remaining == 0 0 0 0
351 } elsif ($plan->{mode} eq 'close') {
352 2 $self->_queue_output($bytes);
353 2 ▶ $tx->_mark_local_done if $final;
Branch: 1 branch
BranchTrueFalseTotal
if $final 1 1 2
354 } else {
355 0 croak 'write(): invalid streaming response framing mode';
356 }
357  
358 9 ▶ if ($tx->{local_done}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($tx->{"local_done"}) 4 5 9
359 4 ▶ $tx->{keep_alive} = $plan->{keep_alive} ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$plan->{'keep_alive'} ? : 3 1 4
360 4 $self->_retire_if_done;
361 }
362 9 ▶ $self->_transport_sync if $self->{transport_attached};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"transport_attached"} 2 7 9
363 9 my $ok = $self->_stream_ok;
364 9 ▶ $tx->{blocked} = 1 unless $ok;
Branch: 1 branch
BranchTrueFalseTotal
unless $ok 2 7 9
365 9 return $ok;
366 }
367  
368 106 ▶sub _retire_if_done {
Subroutine _retire_if_done: called CC=15 SCAR=27.2
369 106 my ($self) = @_;
370 106 ▶ my $tx = $self->{active} or return;
Branch: 1 branch
BranchTrueFalseTotal
my $tx = $self->{"active"} or return 97 9 106
371 97 ▶ return unless $tx->{local_done} && $tx->{remote_done};
Branch: 1 branch
BranchTrueFalseTotal
unless $tx->{"local_done"} and $tx->{"remote_done"} 47 50 97
Condition100%3/3
$tx->{"local_done"} and $tx->{"remote_done"}
!ll&&!rl&&r
74050
MC/DC100%2/2
$tx->{"local_done"} and $tx->{"remote_done"}
$tx->{"local_done"} $tx->{"remote_done"}
Truth table100%3/3
A and B
A= $tx->{"local_done"}B= $tx->{"remote_done"}
ABresult
0X0
100
111
372 50 ▶ if ($tx->{switch_pending}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($tx->{"switch_pending"}) 8 42 50
373 8 ▶ $tx->_mark_complete unless $tx->is_terminal;
Branch: 1 branch
BranchTrueFalseTotal
unless $tx->is_terminal 8 0 8
374 8 my $response = $tx->response;
375 8 $self->_mark_switched;
376 8 $self->{active} = undef;
377 8 ▶ if ($self->{transport_attached}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"transport_attached"}) 3 5 8
378 3 $self->{switch_notice} = [ $tx, $response ];
379 3 ▶ $self->_transport_sync if $self->{transport_attached};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"transport_attached"} 3 0 3
380 3 return;
381 }
382 5 return $self->_deliver_switch_notice($tx, $response);
383 }
384 42 ▶ $tx->_mark_complete unless $tx->is_terminal;
Branch: 1 branch
BranchTrueFalseTotal
unless $tx->is_terminal 42 0 42
385 42 my $keep = $tx->{keep_alive};
386 42 ▶ $keep = $tx->{request_keep_alive} unless defined $keep;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $keep 0 42 42
387 42 $self->{active} = undef;
388 42 ▶ if (!$keep || $self->{eof}) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $keep or $self->{"eof"}) 12 30 42
Condition100%3/3
not $keep or $self->{"eof"}
l!l&&r!l&&!r
11130
MC/DC100%2/2
not $keep or $self->{"eof"}
not $keep $self->{"eof"}
Truth table100%3/3
not(A) or B
A= not $keepB= $self->{"eof"}
ABresult
1X1
011
000
389 12 $self->{closed} = 1;
390 12 ▶ $self->_transport_sync if $self->{transport_attached};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"transport_attached"} 3 9 12
391 12 return;
392 }
393 30 ▶ return if $self->{driving};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"driving"} 27 3 30
394 3 local $self->{driving} = 1;
395 3 ▶ $self->_drive if $self->_input_length;
Branch: 1 branch
BranchTrueFalseTotal
if $self->_input_length 0 3 3
396 3 return;
397 }
398  
399 8 ▶sub _deliver_switch_notice {
Subroutine _deliver_switch_notice: called CC=3 SCAR=11.2
400 8 my ($self, $tx, $response) = @_;
401 8 my $cb = $self->_invoke_server('on_switch', $tx, $response);
402 8 ▶ if ($cb ne '1') {
Branch: 1 branch
BranchTrueFalseTotal
if ($cb ne 1) 1 7 8
403 1 ▶ if ($self->{transport_attached}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'transport_attached'}) { } 1 0 1
404 1 $self->_transport_abort($cb);
405 } else {
406 0 $self->_application_error($cb);
407 }
408 }
409 8 return;
410 }
411  
412 0 ▶sub _transaction_cancel {
Subroutine _transaction_cancel: not called CC=5 SCAR=34.0
413 0 my ($self, $tx) = @_;
414 0 ▶ return if $tx->is_terminal;
Branch: 1 branch
BranchTrueFalseTotal
if $tx->is_terminal 0 0 0
415 0 $tx->_mark_cancelled;
416 0 ▶ $self->{active} = undef if $self->{active} && $self->{active} == $tx;
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"active"} and $self->{"active"} == $tx 0 0 0
Condition0%0/3
$self->{"active"} and $self->{"active"} == $tx
!ll&&!rl&&r
000
MC/DC0%0/2
$self->{"active"} and $self->{"active"} == $tx
$self->{"active"} $self->{"active"} == $tx
Truth table0%0/3
A and B
A= $self->{"active"}B= $self->{"active"} == $tx
ABresult
0X0
100
111
417 0 $self->{rx} = undef;
418 0 $self->{closed} = 1;
419 $self->_transport_abort('HTTP/1 transaction cancelled')
420 0 ▶ if $self->{transport_attached};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"transport_attached"} 0 0 0
421 0 return;
422 }
423  
424 41 ▶sub _maybe_drain {
Subroutine _maybe_drain: called CC=4 SCAR=13.9
425 41 my ($self) = @_;
426 41 ▶ my $tx = $self->{active} or return;
Branch: 1 branch
BranchTrueFalseTotal
my $tx = $self->{"active"} or return 9 32 41
427 9 ▶ return unless $tx->{blocked};
Branch: 1 branch
BranchTrueFalseTotal
unless $tx->{"blocked"} 7 2 9
428 2 $tx->{blocked} = 0;
429 2 my $cb = $tx->_invoke('on_drain');
430 2 ▶ $self->_application_error($cb) unless $cb eq '1';
Branch: 1 branch
BranchTrueFalseTotal
unless $cb eq 1 0 2 2
431 2 return;
432 }
433  
434 135 ▶sub _invoke_server {
Subroutine _invoke_server: called CC=3 SCAR=11.0
435 135 my ($self, $name, @args) = @_;
436 135 ▶ my $cb = $self->{callbacks}{$name} or return 1;
Branch: 1 branch
BranchTrueFalseTotal
my $cb = $self->{"callbacks"}{$name} or return 1 98 37 135
437 98 my $ok = eval { $cb->(@args); 1 };
438 98 ▶ return $ok ? 1 : "$@";
Branch: 1 branch
BranchTrueFalseTotal
$ok ? : 92 6 98
439 }
440  
441 5 ▶sub _application_error {
Subroutine _application_error: called CC=9 SCAR=26.8
442 5 my ($self, $error) = @_;
443 5 ▶ $error = 'HTTP/1 server callback failed' unless defined($error) && length($error);
Branch: 1 branch
BranchTrueFalseTotal
unless defined $error and length $error 0 5 5
Condition33%1/3
defined $error and length $error
!ll&&!rl&&r
005
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
444 5 my $tx = $self->{active};
445 5 ▶ if ($tx && !$tx->response && !$self->{switched}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($tx and not $tx->response and not $self->{"switched"}) 5 0 5
Condition33%2/6
$tx and not $tx->response and not $self->{"switched"}
!ll&&!rl&&r
005
$tx and not $tx->response
!ll&&!rl&&r
005
MC/DC0%0/3
$tx and not $tx->response and not $self->{"switched"}
$tx not $tx->response not $self->{"switched"}
Truth table25%1/4
A and not(B) and not(C)
A= $txB= not $tx->responseC= not $self->{"switched"}
ABCresult
0XX0
10X0
1100
1111
446 5 eval {
447 5 my $response = Uniform::HTTP::Response->new(status => 500, body => '');
448 5 $self->_transaction_respond($tx, $response);
449 5 1;
450 };
451 }
452 5 $self->{closed} = 1;
453 5 ▶ $tx->_fail($error) if $tx && !$tx->is_terminal;
Branch: 1 branch
BranchTrueFalseTotal
if $tx and not $tx->is_terminal 5 0 5
Condition33%1/3
$tx and not $tx->is_terminal
!ll&&!rl&&r
005
MC/DC0%0/2
$tx and not $tx->is_terminal
$tx not $tx->is_terminal
Truth table33%1/3
A and not(B)
A= $txB= not $tx->is_terminal
ABresult
0X0
100
111
454 5 ▶ if (my $cb = $self->{callbacks}{on_error}) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $cb = $self->{"callbacks"}{"on_error"}) 0 5 5
455 0 eval { $cb->($tx, $error) };
456 }
457 5 return;
458 }
459  
460 5 ▶sub _protocol_error {
Subroutine _protocol_error: called CC=12 SCAR=27.8
461 5 my ($self, $status, $detail) = @_;
462 5 ▶ return if $self->{closed};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"closed"} 0 5 5
463 5 ▶ my $reason = $status == 400 ? 'Bad Request'
Branch: 5 branches
BranchTrueFalseTotal
$status == 400 ? : 2 3 5
$status == 417 ? : 1 2 3
$status == 431 ? : 2 0 2
$status == 501 ? : 0 0 0
$status == 505 ? : 0 0 0
464 : $status == 417 ? 'Expectation Failed'
465 : $status == 431 ? 'Request Header Fields Too Large'
466 : $status == 501 ? 'Not Implemented'
467 : $status == 505 ? 'HTTP Version Not Supported'
468 : 'Bad Request';
469 5 my $wire = 'HTTP/1.1 ' . $status . ' ' . $reason . "\r\n"
470 . "Content-Length: 0\r\nConnection: close\r\n\r\n";
471 5 $self->_queue_output($wire);
472 5 $self->{closed} = 1;
473 5 ▶ if (my $tx = $self->{active}) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $tx = $self->{"active"}) 1 4 5
474 1 ▶ $tx->_fail($detail || $reason) unless $tx->is_terminal;
Branch: 1 branch
BranchTrueFalseTotal
unless $tx->is_terminal 1 0 1
Condition33%1/3
$detail || $reason
l!l&&r!l&&!r
100
MC/DC0%0/2
$detail || $reason
$detail $reason
Truth table33%1/3
A || B
A= $detailB= $reason
ABresult
1X1
011
000
475 }
476 5 ▶ if (my $cb = $self->{callbacks}{on_error}) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $cb = $self->{"callbacks"}{"on_error"}) 1 4 5
477 1 ▶ eval { $cb->($self->{active}, $detail || $reason) };
Condition33%1/3
$detail || $reason
l!l&&r!l&&!r
100
MC/DC0%0/2
$detail || $reason
$detail $reason
Truth table33%1/3
A || B
A= $detailB= $reason
ABresult
1X1
011
000
478 }
479 5 return;
480 }
481  
482 0 ▶sub _borrowed_should_buffer_tail {
Subroutine _borrowed_should_buffer_tail: not called CC=3 SCAR=24.8
483 0 my ($self) = @_;
484 0 ▶ return $self->{active} && !$self->{rx} ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$self->{'active'} && !$self->{'rx'} ? : 0 0 0
Condition0%0/3
$self->{"active"} and not $self->{"rx"}
!ll&&!rl&&r
000
MC/DC0%0/2
$self->{"active"} and not $self->{"rx"}
$self->{"active"} not $self->{"rx"}
Truth table0%0/3
A and not(B)
A= $self->{"active"}B= not $self->{"rx"}
ABresult
0X0
100
111
485 }
486  
487 10 ▶sub _borrowed_native_head_ready {
Subroutine _borrowed_native_head_ready: called CC=6 SCAR=18.2
488 10 my ($self) = @_;
489 10 ▶ return 0 if $self->{closed} || $self->{switched};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"closed"} or $self->{"switched"} 2 8 10
Condition66%2/3
$self->{"closed"} or $self->{"switched"}
l!l&&r!l&&!r
028
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
490 8 ▶ return 0 if $self->{active} || $self->{rx};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"active"} or $self->{"rx"} 2 6 8
Condition66%2/3
$self->{"active"} or $self->{"rx"}
l!l&&r!l&&!r
206
MC/DC50%1/2
$self->{"active"} or $self->{"rx"}
$self->{"active"} $self->{"rx"}
Truth table66%2/3
A or B
A= $self->{"active"}B= $self->{"rx"}
ABresult
1X1
011
000
491 6 ▶ return 0 if length $self->{input};
Branch: 1 branch
BranchTrueFalseTotal
if length $self->{"input"} 0 6 6
492 6 return 1;
493 }
494  
495 1 ▶sub _on_eof {
Subroutine _on_eof: called CC=6 SCAR=26.8
496 1 my ($self) = @_;
497 1 ▶ return if $self->{switched};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"switched"} 0 1 1
498 1 ▶ if ($self->{active} && $self->{active}{remote_done}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"active"} and $self->{"active"}{"remote_done"}) 1 0 1
Condition33%1/3
$self->{"active"} and $self->{"active"}{"remote_done"}
!ll&&!rl&&r
001
MC/DC0%0/2
$self->{"active"} and $self->{"active"}{"remote_done"}
$self->{"active"} $self->{"active"}{"remote_done"}
Truth table33%1/3
A and B
A= $self->{"active"}B= $self->{"active"}{"remote_done"}
ABresult
0X0
100
111
499 # A fully received request may still have a delayed application
500 # response. Read EOF prevents reuse but does not cancel that reply.
501 1 $self->{active}{request_keep_alive} = 0;
502 1 return;
503 }
504 0 ▶ if ($self->{active} || length($self->{input})) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'active'} or length $self->{'input'}) { } 0 0 0
Condition0%0/3
$self->{"active"} or length $self->{"input"}
l!l&&r!l&&!r
000
MC/DC0%0/2
$self->{"active"} or length $self->{"input"}
$self->{"active"} length $self->{"input"}
Truth table0%0/3
A or B
A= $self->{"active"}B= length $self->{"input"}
ABresult
1X1
011
000
505 0 $self->_protocol_error(400, 'unexpected EOF in HTTP/1 request');
506 } else {
507 0 $self->{closed} = 1;
508 }
509 0 return;
510 }
511  
512 4 ▶sub _fail_all {
Subroutine _fail_all: called CC=4 SCAR=14.8
513 4 my ($self, $error) = @_;
514 4 ▶ if (my $tx = delete $self->{active}) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $tx = delete $self->{"active"}) 0 4 4
515 0 ▶ $tx->_fail($error) unless $tx->is_terminal;
Branch: 1 branch
BranchTrueFalseTotal
unless $tx->is_terminal 0 0 0
516 }
517 4 $self->{rx} = undef;
518 4 ▶ if (my $cb = $self->{callbacks}{on_error}) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $cb = $self->{"callbacks"}{"on_error"}) 1 3 4
519 1 eval { $cb->(undef, $error) };
520 }
521 4 return;
522 }
523  
524 22 1;
525  
526 __END__
« blib/lib/Unblock/HTTP1/Client.pm ↑ Summary blib/lib/Unblock/HTTP1/_Engine.pm »