Branch Coverage

blib/lib/Starlet/Server.pm
Criterion Covered Total %
branch 115 180 63.8


line true false branch
51 1 113 defined $args{'min_reqs_per_child'} ? :
0 114 defined $args{'err_respawn_interval'} ? :
56 0 114 if ($args{'max_workers'} and $args{'max_workers'} > 1)
74 104 9 if (scalar grep({defined $_;} @{$$self{'listens'};}) == 0)
76 98 6 if ($self->{'port'} =~ /^[0-9]+$/s) { }
81 0 98 unless $sock = 'IO::Socket::INET'->new('Listen', 128, 'LocalPort', $self->{'port'}, 'LocalAddr', $self->{'host'}, 'Proto', 'tcp', 'ReuseAddr', 1)
88 0 6 unless $sock = 'IO::Socket::UNIX'->new('Listen', 128, 'Local', $self->{'port'})
103 107 24 if ($^O eq 'linux' and $listen->{'_is_tcp'})
105 107 0 if setsockopt $listen->{'sock'}, 6, 9, 1
109 3 110 if (scalar @listens > 1)
138 84 188 if $self->{'term_received'}
140 84 104 unless $conn
143 0 104 unless defined $conn->blocking(0)
146 98 6 if ($listen->{'_is_tcp'})
147 0 98 unless $conn->setsockopt(6, 1, 1)
178 0 0 if ($may_keepalive and $max_reqs_per_child and $proc_req_count >= $max_reqs_per_child)
181 0 104 if length $pipelined_buf
186 16 87 if ($env->{'psgix.harakiri.commit'})
190 87 0 unless $keepalive
201 99 2 if (scalar @listens == 1) { }
204 97 82 if (my($conn, $peer) = $listen->{'sock'}->accept)
215 0 14 unless defined $listen->{'sock'}->blocking(0)
223 0 2 unless open my $lock_fh, '>', $self->{'lock_path'}
226 1 8 unless (flock $lock_fh, 2)
227 0 1 if $! != 4
234 21 7 unless vec $rout, $fd, 1
237 7 0 if (my($conn, $peer) = $listen->{'sock'}->accept)
258 0 104 if ($rlen = length $prebuf) { }
266 0 104 $is_keepalive ? :
10 94 unless $rlen = $self->read_timeout($conn, \$buf, 131072 - length($buf), length $buf, $is_keepalive ? $self->{'keepalive_timeout'} : $self->{'timeout'})
269 93 1 if ($reqlen >= 0)
272 0 93 if ($use_keepalive)
273 0 0 if ($self->{'term_received'}) { }
0 0 elsif ($protocol eq 'HTTP/1.1') { }
276 0 0 if (my $c = $env->{'HTTP_CONNECTION'})
277 0 0 if $c =~ /^\s*close\s*/i
281 0 0 if (my $c = $env->{'HTTP_CONNECTION'}) { }
282 0 0 unless $c =~ /^\s*keep-alive\s*/i
291 5 88 if (my $cl = $env->{'CONTENT_LENGTH'}) { }
1 87 elsif ($chunked) { }
295 4 1 if (length $buf) { }
301 1 0 unless $self->read_timeout($conn, \$chunk, $cl, 0, $self->{'timeout'})
314 1 2 if (length $buf) { }
320 0 2 unless $self->read_timeout($conn, \$chunk, 65536, 0, $self->{'timeout'})
327 1 78 if ($chunk_len == 0) { }
0 78 elsif (length $chunk_buffer < $chunk_len + 2) { }
341 0 87 if ($buf =~ /^(?:GET|HEAD)/)
348 0 92 if ($env->{'HTTP_EXPECT'})
349 0 0 if ($env->{'HTTP_EXPECT'} eq '100-continue') { }
350 0 0 unless $self->write_all($conn, "HTTP/1.1 100 Continue\r\n\r\n")
361 0 1 if ($reqlen == -2) { }
1 0 elsif ($reqlen == -1) { }
369 89 3 if (ref $res eq 'ARRAY') { }
3 0 elsif (ref $res eq 'CODE') { }
394 1 106 if ($lck eq 'connection') { }
395 0 1 if $$use_keepalive_r and lc $v ne 'keep-alive'
402 91 1 unless (exists $send_headers{'server'})
405 92 0 unless (exists $send_headers{'date'})
411 81 11 if (defined $protocol and $protocol eq 'HTTP/1.1') { }
412 4 77 if (defined $send_headers{'content-length'} or defined $send_headers{'transfer-encoding'}) { }
76 1 elsif (not Plack::Util::status_with_no_entity_body($status_code)) { }
419 81 0 unless $$use_keepalive_r
422 0 11 if ($$use_keepalive_r)
423 0 0 if (defined $send_headers{'content-length'} or defined $send_headers{'transfer-encoding'}) { }
0 0 elsif (not Plack::Util::status_with_no_entity_body($status_code) and defined(my $cl = Plack::Util::content_length($body))) { }
433 0 11 if $$use_keepalive_r
434 11 0 unless $$use_keepalive_r
440 82 3 if (defined $body and ref $body eq 'ARRAY' and @$body == 1 and length $body->[0] < 8192)
444 70 12 if ($use_chunked)
454 0 10 unless $self->write_all($conn, join('', @lines), $self->{'timeout'})
456 8 2 if (defined $body) { }
459 3 5 ref $body eq 'ARRAY' ? :
463 10 0 unless ($failed)
466 7 3 if ($use_chunked)
468 0 7 unless $len
470 2 5 if ($body_count == 0)
476 0 10 unless $self->write_all($conn, $buf, $self->{'timeout'})
480 2 6 if $use_chunked and not $completed
485 5 0 if ($use_chunked)
487 1 4 unless $len
493 2 0 if $use_chunked
502 9 98 unless ($is_write or delete $self->{'_is_deferred_accept'})
507 110 107 if ($is_write) { }
508 110 0 if $ret = syswrite($sock, $buf, $len, $off)
511 96 11 if $ret = sysread($sock, $$buf, $len, $off)
514 11 0 unless (not defined $ret and $! == 4 || $! == 11 || $! == 11)
524 0 9 if ($is_write) { }
532 9 0 if $nfound
533 0 0 if $timeout <= 0
555 0 110 unless my $ret = $self->write_timeout($sock, $buf, $len, $off, $timeout)