Skip to content
Merged
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
1 change: 0 additions & 1 deletion src/Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ function ($stream) use ($requestData, &$streamRef, &$stateRef) {
$stream->on('end', array($this, 'handleEnd'));
$stream->on('error', array($this, 'handleError'));

$requestData->setProtocolVersion('1.0');
$headers = (string) $requestData;

$stream->write($headers);
Expand Down
2 changes: 1 addition & 1 deletion src/RequestData.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class RequestData
private $url;
private $headers;

private $protocolVersion = '1.1';
private $protocolVersion = '1.0';

public function __construct($method, $url, array $headers = [])
{
Expand Down
17 changes: 15 additions & 2 deletions tests/RequestDataTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,20 @@ public function toStringReturnsHTTPRequestMessage()
{
$requestData = new RequestData('GET', 'http://www.example.com');

$expected = "GET / HTTP/1.0\r\n" .
"Host: www.example.com\r\n" .
"User-Agent: React/alpha\r\n" .
"\r\n";

$this->assertSame($expected, $requestData->__toString());
}

/** @test */
public function toStringReturnsHTTPRequestMessageWithProtocolVersion()
{
$requestData = new RequestData('GET', 'http://www.example.com');
$requestData->setProtocolVersion('1.1');

$expected = "GET / HTTP/1.1\r\n" .
"Host: www.example.com\r\n" .
"User-Agent: React/alpha\r\n" .
Expand All @@ -25,10 +39,9 @@ public function toStringUsesUserPassFromURL()
{
$requestData = new RequestData('GET', 'http://john:dummy@www.example.com');

$expected = "GET / HTTP/1.1\r\n" .
$expected = "GET / HTTP/1.0\r\n" .
"Host: www.example.com\r\n" .
"User-Agent: React/alpha\r\n" .
"Connection: close\r\n" .
"Authorization: Basic am9objpkdW1teQ==\r\n" .
"\r\n";

Expand Down