Skip to content

Commit a333f46

Browse files
committed
Support explicitly using HTTP/1.1 protocol version
Still defaults to HTTP/1.0 and offers only limited support
1 parent dcb6923 commit a333f46

File tree

3 files changed

+16
-4
lines changed

3 files changed

+16
-4
lines changed

src/Request.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,6 @@ function ($stream) use ($requestData, &$streamRef, &$stateRef) {
6868
$stream->on('end', array($this, 'handleEnd'));
6969
$stream->on('error', array($this, 'handleError'));
7070

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

7473
$stream->write($headers);

src/RequestData.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ class RequestData
88
private $url;
99
private $headers;
1010

11-
private $protocolVersion = '1.1';
11+
private $protocolVersion = '1.0';
1212

1313
public function __construct($method, $url, array $headers = [])
1414
{

tests/RequestDataTest.php

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,20 @@ public function toStringReturnsHTTPRequestMessage()
1111
{
1212
$requestData = new RequestData('GET', 'http://www.example.com');
1313

14+
$expected = "GET / HTTP/1.0\r\n" .
15+
"Host: www.example.com\r\n" .
16+
"User-Agent: React/alpha\r\n" .
17+
"\r\n";
18+
19+
$this->assertSame($expected, $requestData->__toString());
20+
}
21+
22+
/** @test */
23+
public function toStringReturnsHTTPRequestMessageWithProtocolVersion()
24+
{
25+
$requestData = new RequestData('GET', 'http://www.example.com');
26+
$requestData->setProtocolVersion('1.1');
27+
1428
$expected = "GET / HTTP/1.1\r\n" .
1529
"Host: www.example.com\r\n" .
1630
"User-Agent: React/alpha\r\n" .
@@ -25,10 +39,9 @@ public function toStringUsesUserPassFromURL()
2539
{
2640
$requestData = new RequestData('GET', 'http://john:[email protected]');
2741

28-
$expected = "GET / HTTP/1.1\r\n" .
42+
$expected = "GET / HTTP/1.0\r\n" .
2943
"Host: www.example.com\r\n" .
3044
"User-Agent: React/alpha\r\n" .
31-
"Connection: close\r\n" .
3245
"Authorization: Basic am9objpkdW1teQ==\r\n" .
3346
"\r\n";
3447

0 commit comments

Comments
 (0)