diff --git a/src/Response.php b/src/Response.php index 36e375fc..d8cf863e 100644 --- a/src/Response.php +++ b/src/Response.php @@ -12,7 +12,8 @@ class Response extends EventEmitter implements WritableStreamInterface private $writable = true; private $conn; private $headWritten = false; - private $chunkedEncoding = true; + // TODO chunked is a HTTP/1.1 feature that needs proper Request parsing before enabling + private $chunkedEncoding = false; public function __construct(ConnectionInterface $conn) { @@ -74,7 +75,7 @@ private function formatHead($status, array $headers) { $status = (int) $status; $text = isset(ResponseCodes::$statusTexts[$status]) ? ResponseCodes::$statusTexts[$status] : ''; - $data = "HTTP/1.1 $status $text\r\n"; + $data = "HTTP/1.0 $status $text\r\n"; foreach ($headers as $name => $value) { $name = str_replace(array("\r", "\n"), '', $name); diff --git a/tests/ResponseTest.php b/tests/ResponseTest.php index 7692fb83..12b2d0c7 100644 --- a/tests/ResponseTest.php +++ b/tests/ResponseTest.php @@ -9,7 +9,7 @@ class ResponseTest extends TestCase public function testResponseShouldBeChunkedByDefault() { $expected = ''; - $expected .= "HTTP/1.1 200 OK\r\n"; + $expected .= "HTTP/1.0 200 OK\r\n"; $expected .= "X-Powered-By: React/alpha\r\n"; $expected .= "Transfer-Encoding: chunked\r\n"; $expected .= "\r\n"; @@ -27,7 +27,7 @@ public function testResponseShouldBeChunkedByDefault() public function testResponseShouldNotBeChunkedWithContentLength() { $expected = ''; - $expected .= "HTTP/1.1 200 OK\r\n"; + $expected .= "HTTP/1.0 200 OK\r\n"; $expected .= "X-Powered-By: React/alpha\r\n"; $expected .= "Content-Length: 22\r\n"; $expected .= "\r\n"; @@ -97,7 +97,7 @@ public function writeContinueShouldSendContinueLineBeforeRealHeaders() $conn ->expects($this->at(4)) ->method('write') - ->with($this->stringContains("HTTP/1.1 200 OK\r\n")); + ->with($this->stringContains("HTTP/1.0 200 OK\r\n")); $response = new Response($conn); $response->writeContinue(); @@ -128,7 +128,7 @@ public function shouldForwardEndDrainAndErrorEvents() public function shouldRemoveNewlinesFromHeaders() { $expected = ''; - $expected .= "HTTP/1.1 200 OK\r\n"; + $expected .= "HTTP/1.0 200 OK\r\n"; $expected .= "X-Powered-By: React/alpha\r\n"; $expected .= "FooBar: BazQux\r\n"; $expected .= "Transfer-Encoding: chunked\r\n"; @@ -148,7 +148,7 @@ public function shouldRemoveNewlinesFromHeaders() public function missingStatusCodeTextShouldResultInNumberOnlyStatus() { $expected = ''; - $expected .= "HTTP/1.1 700 \r\n"; + $expected .= "HTTP/1.0 700 \r\n"; $expected .= "X-Powered-By: React/alpha\r\n"; $expected .= "Transfer-Encoding: chunked\r\n"; $expected .= "\r\n"; @@ -167,7 +167,7 @@ public function missingStatusCodeTextShouldResultInNumberOnlyStatus() public function shouldAllowArrayHeaderValues() { $expected = ''; - $expected .= "HTTP/1.1 200 OK\r\n"; + $expected .= "HTTP/1.0 200 OK\r\n"; $expected .= "X-Powered-By: React/alpha\r\n"; $expected .= "Set-Cookie: foo=bar\r\n"; $expected .= "Set-Cookie: bar=baz\r\n"; @@ -188,7 +188,7 @@ public function shouldAllowArrayHeaderValues() public function shouldIgnoreHeadersWithNullValues() { $expected = ''; - $expected .= "HTTP/1.1 200 OK\r\n"; + $expected .= "HTTP/1.0 200 OK\r\n"; $expected .= "X-Powered-By: React/alpha\r\n"; $expected .= "Transfer-Encoding: chunked\r\n"; $expected .= "\r\n";