Skip to content

Commit

Permalink
Merge pull request #43 from clue-labs/version
Browse files Browse the repository at this point in the history
Support explicitly using HTTP/1.1 protocol version
  • Loading branch information
WyriHaximus committed Sep 3, 2015
2 parents dcb6923 + a333f46 commit d6e02ad
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
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:[email protected]');

$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

0 comments on commit d6e02ad

Please sign in to comment.