diff --git a/tests/Io/StreamingServerTest.php b/tests/Io/StreamingServerTest.php index 59cfd118..45729f2b 100644 --- a/tests/Io/StreamingServerTest.php +++ b/tests/Io/StreamingServerTest.php @@ -1426,6 +1426,38 @@ function ($data) use (&$buffer) { $this->assertContainsString("\r\nContent-Length: 3\r\n", $buffer); } + public function testResponseContainsExplicitContentLengthHeaderForHeadRequests() + { + $server = new StreamingServer(Loop::get(), function (ServerRequestInterface $request) { + return new Response( + 200, + array('Content-Length' => 3), + '' + ); + }); + + $buffer = ''; + $this->connection + ->expects($this->any()) + ->method('write') + ->will( + $this->returnCallback( + function ($data) use (&$buffer) { + $buffer .= $data; + } + ) + ); + + $server->listen($this->socket); + $this->socket->emit('connection', array($this->connection)); + + $data = "HEAD / HTTP/1.1\r\nHost: localhost\r\n\r\n"; + $this->connection->emit('data', array($data)); + + $this->assertContainsString("HTTP/1.1 200 OK\r\n", $buffer); + $this->assertContainsString("\r\nContent-Length: 3\r\n", $buffer); + } + public function testResponseContainsNoResponseBodyForNotModifiedStatus() { $server = new StreamingServer(Loop::get(), function (ServerRequestInterface $request) {