t/httpd-corner.psgi | 2 +- t/httpd-corner.t | 19 ++++++++++++------- diff --git a/t/httpd-corner.psgi b/t/httpd-corner.psgi index bf38d1ff7995ddf1c8ee2447ccf1c956147f9419..18e556be0e39c29c5ca20f64ddbb4953da8052b4 100644 --- a/t/httpd-corner.psgi +++ b/t/httpd-corner.psgi @@ -87,7 +87,7 @@ [ 200, [ qw(Content-Type application/octet-stream) ]]; }); } elsif ($path eq '/pid') { $code = 200; - push @$body, $$; + push @$body, "$$\n"; } [ $code, $h, $body ] diff --git a/t/httpd-corner.t b/t/httpd-corner.t index b063d9fa8d9f9658e1ef54f2e7c699b8faa51030..cc36c7e10c87fc90d4477d2c59b1f3340caeb4ad 100644 --- a/t/httpd-corner.t +++ b/t/httpd-corner.t @@ -76,17 +76,22 @@ $spawn_httpd->(); if ('test worker death') { my $conn = conn_for($sock, 'killed worker'); - $conn->write("GET /pid HTTP/1.0\r\n\r\n"); - ok($conn->read(my $buf, 8192), 'read response'); - my ($head, $body) = split(/\r\n\r\n/, $buf); - like($body, qr/\A[0-9]+\z/, '/pid response'); - my $pid = $body; + $conn->write("GET /pid HTTP/1.1\r\nHost:example.com\r\n\r\n"); + my $pid; + while (defined(my $line = $conn->getline)) { + next unless $line eq "\r\n"; + chomp($pid = $conn->getline); + last; + } + like($pid, qr/\A[0-9]+\z/, '/pid response'); is(kill('KILL', $pid), 1, 'killed worker'); + is($conn->getline, undef, 'worker died and EOF-ed client'); $conn = conn_for($sock, 'respawned worker'); $conn->write("GET /pid HTTP/1.0\r\n\r\n"); - ok($conn->read($buf, 8192), 'read response'); - ($head, $body) = split(/\r\n\r\n/, $buf); + ok($conn->read(my $buf, 8192), 'read response'); + my ($head, $body) = split(/\r\n\r\n/, $buf); + chomp($body); like($body, qr/\A[0-9]+\z/, '/pid response'); isnt($body, $pid, 'respawned worker'); }