Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/Response.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down Expand Up @@ -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);
Expand Down
14 changes: 7 additions & 7 deletions tests/ResponseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand All @@ -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";
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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";
Expand All @@ -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";
Expand All @@ -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";
Expand All @@ -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";
Expand Down