Branch Coverage

blib/lib/Starlet/Server.pm
Criterion Covered Total %
branch 116 180 64.4


line true false branch
54 1 111 defined $args{'min_reqs_per_child'} ? :
0 112 defined $args{'err_respawn_interval'} ? :
57 0 112 if ($args{'max_workers'} and $args{'max_workers'} > 1)
75 102 9 if (scalar grep({defined $_;} @{$$self{'listens'};}) == 0)
77 96 6 if ($self->{'port'} =~ /^[0-9]+$/s) { }
82 0 96 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 105 24 if ($^O eq 'linux' and $listen->{'_is_tcp'})
106 105 0 if setsockopt $listen->{'sock'}, 6, 9, 1
110 3 108 if (scalar @listens > 1)
139 83 185 if ($self->{'term_received'})
144 83 102 unless $conn
147 0 102 unless defined $conn->blocking(0)
150 96 6 if ($listen->{'_is_tcp'})
151 0 96 unless $conn->setsockopt(6, 1, 1)
182 0 0 if ($may_keepalive and $max_reqs_per_child and $proc_req_count >= $max_reqs_per_child)
185 0 102 if length $pipelined_buf
190 14 87 if ($env->{'psgix.harakiri.commit'})
194 87 0 unless $keepalive
205 96 2 if (scalar @listens == 1) { }
208 95 81 if (my($conn, $peer) = $listen->{'sock'}->accept)
219 0 14 unless defined $listen->{'sock'}->blocking(0)
227 0 2 unless open my $lock_fh, '>', $self->{'lock_path'}
230 1 8 unless (flock $lock_fh, 2)
231 0 1 if $! != 4
238 21 7 unless vec $rout, $fd, 1
241 7 0 if (my($conn, $peer) = $listen->{'sock'}->accept)
262 0 102 if ($rlen = length $prebuf) { }
270 0 102 $is_keepalive ? :
10 92 unless $rlen = $self->read_timeout($conn, \$buf, 131072 - length($buf), length $buf, $is_keepalive ? $self->{'keepalive_timeout'} : $self->{'timeout'})
273 91 1 if ($reqlen >= 0)
276 0 91 if ($use_keepalive)
277 0 0 if ($self->{'term_received'}) { }
0 0 elsif ($protocol eq 'HTTP/1.1') { }
280 0 0 if (my $c = $env->{'HTTP_CONNECTION'})
281 0 0 if $c =~ /^\s*close\s*/i
285 0 0 if (my $c = $env->{'HTTP_CONNECTION'}) { }
286 0 0 unless $c =~ /^\s*keep-alive\s*/i
295 5 86 if (my $cl = $env->{'CONTENT_LENGTH'}) { }
1 85 elsif ($chunked) { }
299 4 1 if (length $buf) { }
305 1 0 unless $self->read_timeout($conn, \$chunk, $cl, 0, $self->{'timeout'})
318 1 48 if (length $buf) { }
324 0 48 unless $self->read_timeout($conn, \$chunk, 65536, 0, $self->{'timeout'})
331 1 78 if ($chunk_len == 0) { }
0 78 elsif (length $chunk_buffer < $chunk_len + 2) { }
345 0 85 if ($buf =~ /^(?:GET|HEAD)/)
352 0 90 if ($env->{'HTTP_EXPECT'})
353 0 0 if ($env->{'HTTP_EXPECT'} eq '100-continue') { }
354 0 0 unless $self->write_all($conn, "HTTP/1.1 100 Continue\r\n\r\n")
365 0 1 if ($reqlen == -2) { }
1 0 elsif ($reqlen == -1) { }
373 87 3 if (ref $res eq 'ARRAY') { }
3 0 elsif (ref $res eq 'CODE') { }
398 1 104 if ($lck eq 'connection') { }
399 0 1 if $$use_keepalive_r and lc $v ne 'keep-alive'
406 89 1 unless (exists $send_headers{'server'})
409 90 0 unless (exists $send_headers{'date'})
415 79 11 if (defined $protocol and $protocol eq 'HTTP/1.1') { }
416 4 75 if (defined $send_headers{'content-length'} or defined $send_headers{'transfer-encoding'}) { }
74 1 elsif (not Plack::Util::status_with_no_entity_body($status_code)) { }
423 79 0 unless $$use_keepalive_r
426 0 11 if ($$use_keepalive_r)
427 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))) { }
437 0 11 if $$use_keepalive_r
438 11 0 unless $$use_keepalive_r
444 80 3 if (defined $body and ref $body eq 'ARRAY' and @$body == 1 and length $body->[0] < 8192)
448 68 12 if ($use_chunked)
458 0 10 unless $self->write_all($conn, join('', @lines), $self->{'timeout'})
460 8 2 if (defined $body) { }
463 3 5 ref $body eq 'ARRAY' ? :
467 10 0 unless ($failed)
470 7 3 if ($use_chunked)
472 0 7 unless $len
474 2 5 if ($body_count == 0)
480 0 10 unless $self->write_all($conn, $buf, $self->{'timeout'})
484 2 6 if $use_chunked and not $completed
489 5 0 if ($use_chunked)
491 1 4 unless $len
497 2 0 if $use_chunked
506 55 96 unless ($is_write or delete $self->{'_is_deferred_accept'})
511 108 152 if ($is_write) { }
512 108 0 if $ret = syswrite($sock, $buf, $len, $off)
515 140 12 if $ret = sysread($sock, $$buf, $len, $off)
518 11 1 unless (not defined $ret and $! == 4 || $! == 11 || $! == 11)
528 0 56 if ($is_write) { }
536 56 0 if $nfound
537 0 0 if $timeout <= 0
559 0 108 unless my $ret = $self->write_timeout($sock, $buf, $len, $off, $timeout)