Branch Coverage

blib/lib/Starlet/Server.pm
Criterion Covered Total %
branch 113 180 62.7


line true false branch
54 1 113 defined $args{'min_reqs_per_child'} ? :
0 114 defined $args{'err_respawn_interval'} ? :
57 0 114 if ($args{'max_workers'} and $args{'max_workers'} > 1)
75 104 9 if (scalar grep({defined $_;} @{$$self{'listens'};}) == 0)
77 98 6 if ($self->{'port'} =~ /^[0-9]+$/s) { }
82 0 98 unless $sock = 'IO::Socket::INET'->new('Listen', 128, 'LocalPort', $self->{'port'}, 'LocalAddr', $self->{'host'}, 'Proto', 'tcp', 'ReuseAddr', 1)
89 0 6 unless $sock = 'IO::Socket::UNIX'->new('Listen', 128, 'Local', $self->{'port'})
104 107 24 if ($^O eq 'linux' and $listen->{'_is_tcp'})
106 107 0 if setsockopt $listen->{'sock'}, 6, 9, 1
110 3 110 if (scalar @listens > 1)
139 84 187 if ($self->{'term_received'})
144 84 103 unless $conn
147 0 103 unless defined $conn->blocking(0)
150 97 6 if ($listen->{'_is_tcp'})
151 0 97 unless $conn->setsockopt(6, 1, 1)
185 0 0 if ($may_keepalive and $max_reqs_per_child and $proc_req_count >= $max_reqs_per_child)
188 0 103 if length $pipelined_buf
193 15 87 if ($env->{'psgix.harakiri.commit'})
197 87 0 unless $keepalive
208 98 2 if (scalar @listens == 1) { }
211 96 82 if (my($conn, $peer) = $listen->{'sock'}->accept)
222 0 14 unless defined $listen->{'sock'}->blocking(0)
230 0 2 unless open my $lock_fh, '>', $self->{'lock_path'}
233 0 9 unless (flock $lock_fh, 2)
234 0 0 if $! != 4
241 21 7 unless vec $rout, $fd, 1
244 7 0 if (my($conn, $peer) = $listen->{'sock'}->accept)
265 0 103 if ($rlen = length $prebuf) { }
273 0 103 $is_keepalive ? :
10 93 unless $rlen = $self->read_timeout($conn, \$buf, 131072 - length($buf), length $buf, $is_keepalive ? $self->{'keepalive_timeout'} : $self->{'timeout'})
276 92 1 if ($reqlen >= 0)
279 0 92 if ($use_keepalive)
280 0 0 if ($self->{'term_received'}) { }
0 0 elsif ($protocol eq 'HTTP/1.1') { }
283 0 0 if (my $c = $env->{'HTTP_CONNECTION'})
284 0 0 if $c =~ /^\s*close\s*/i
288 0 0 if (my $c = $env->{'HTTP_CONNECTION'}) { }
289 0 0 unless $c =~ /^\s*keep-alive\s*/i
299 0 92 if ($env->{'HTTP_EXPECT'})
300 0 0 if (lc $env->{'HTTP_EXPECT'} eq '100-continue') { }
301 0 0 unless $self->write_all($conn, "HTTP/1.1 100 Continue\r\n\r\n")
309 5 87 if (my $cl = $env->{'CONTENT_LENGTH'}) { }
1 86 elsif ($chunked) { }
313 4 1 if (length $buf) { }
319 1 0 unless $self->read_timeout($conn, \$chunk, $cl, 0, $self->{'timeout'})
332 1 2 if (length $buf) { }
338 0 2 unless $self->read_timeout($conn, \$chunk, 65536, 0, $self->{'timeout'})
345 1 78 if ($chunk_len == 0) { }
0 78 elsif (length $chunk_buffer < $chunk_len + 2) { }
359 0 86 if ($buf =~ /^(?:GET|HEAD)/)
369 0 1 if ($reqlen == -2) { }
1 0 elsif ($reqlen == -1) { }
377 88 3 if (ref $res eq 'ARRAY') { }
3 0 elsif (ref $res eq 'CODE') { }
416 1 105 if ($lck eq 'connection') { }
417 0 1 if $$use_keepalive_r and lc $v ne 'keep-alive'
424 90 1 unless (exists $send_headers{'server'})
427 91 0 unless (exists $send_headers{'date'})
433 80 11 if (defined $protocol and $protocol eq 'HTTP/1.1') { }
434 4 76 if (defined $send_headers{'content-length'} or defined $send_headers{'transfer-encoding'}) { }
75 1 elsif (not Plack::Util::status_with_no_entity_body($status_code)) { }
441 80 0 unless $$use_keepalive_r
444 0 11 if ($$use_keepalive_r)
445 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))) { }
455 0 11 if $$use_keepalive_r
456 11 0 unless $$use_keepalive_r
462 81 3 if (defined $body and ref $body eq 'ARRAY' and @$body == 1 and length $body->[0] < 8192)
466 69 12 if ($use_chunked)
476 0 10 unless $self->write_all($conn, join('', @lines), $self->{'timeout'})
478 8 2 if (defined $body) { }
481 3 5 ref $body eq 'ARRAY' ? :
485 10 0 unless ($failed)
488 7 3 if ($use_chunked)
490 0 7 unless $len
492 2 5 if ($body_count == 0)
498 0 10 unless $self->write_all($conn, $buf, $self->{'timeout'})
502 2 6 if $use_chunked and not $completed
507 5 0 if ($use_chunked)
509 1 4 unless $len
515 2 0 if $use_chunked
524 9 97 unless ($is_write or delete $self->{'_is_deferred_accept'})
529 109 106 if ($is_write) { }
530 109 0 if $ret = syswrite($sock, $buf, $len, $off)
533 95 11 if $ret = sysread($sock, $$buf, $len, $off)
536 11 0 unless (not defined $ret and $! == 4 || $! == 11 || $! == 11)
546 0 9 if ($is_write) { }
554 9 0 if $nfound
555 0 0 if $timeout <= 0
577 0 109 unless my $ret = $self->write_timeout($sock, $buf, $len, $off, $timeout)