Skip to content
This repository has been archived by the owner on Jan 30, 2020. It is now read-only.

Commit

Permalink
Merge pull request #161 from DaDeather/master
Browse files Browse the repository at this point in the history
Do not upper case first character of headers in socket adapter
  • Loading branch information
weierophinney committed Jan 8, 2019
2 parents a4eecc6 + e0620b1 commit 993cf91
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/Client/Adapter/Socket.php
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,7 @@ public function write($method, $uri, $httpVer = '1.1', $headers = [], $body = ''
$request = $method . ' ' . $path . ' HTTP/' . $httpVer . "\r\n";
foreach ($headers as $k => $v) {
if (is_string($k)) {
$v = ucfirst($k) . ': ' . $v;
$v = $k . ': ' . $v;
}
$request .= $v . "\r\n";
}
Expand Down
2 changes: 1 addition & 1 deletion src/Client/Adapter/Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ public function write($method, $uri, $httpVer = '1.1', $headers = [], $body = ''
$request = $method . ' ' . $path . ' HTTP/' . $httpVer . "\r\n";
foreach ($headers as $k => $v) {
if (is_string($k)) {
$v = ucfirst($k) . ': ' . $v;
$v = $k . ': ' . $v;
}
$request .= $v . "\r\n";
}
Expand Down
18 changes: 18 additions & 0 deletions test/Client/SocketTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,24 @@ public function testAllowsZeroWrittenBytes()
$this->_adapter->write('GET', new Uri('tcp://localhost:80/'), '1.1', [], 'test body');
}

/**
* Verifies that the headers are being set as given without changing any
* character case.
*/
public function testCaseInsensitiveHeaders()
{
$this->_adapter->connect('localhost');
$requestString = $this->_adapter->write(
'GET',
new Uri('tcp://localhost:80/'),
'1.1',
['x-test-header' => 'someTestHeader'],
'someTestBody'
);

$this->assertContains('x-test-header', $requestString);
}

/**
* Data Providers
*/
Expand Down

0 comments on commit 993cf91

Please sign in to comment.