zendframework / zend-http

Http component from Zend Framework
BSD 3-Clause "New" or "Revised" License
134 stars 85 forks source link

Passed headers are upper cased on first character by default #160

Closed DaDeather closed 5 years ago

DaDeather commented 6 years ago

The passed headers are being made ucfirst() by default. Which is unnecessary according to HTTP 1.1 (https://www.w3.org/Protocols/rfc2616/rfc2616.html and which was not changed in https://tools.ietf.org/html/rfc7230#appendix-A.2).

See: https://github.com/zendframework/zend-http/blob/master/src/Client/Adapter/Socket.php#L384

We are facing an issue were an API provider is checking for a case sensitive x- header (which of course is not HTTP 1.1 compliant).

Code to reproduce the issue

$config = [
    'adapter' => 'Zend\Http\Client\Adapter\Socket',
    'ssltransport' => 'tls'
];
$client = new Client('http://httpbin.org', $config);
$request = new Request();
$request->setUri('http://httpbin.org/get');
$request->setHeaders(Headers::fromString('x-my-test: myTest'));
$response = $client->send($request);

Expected results

The header parameter should have been the way it has been given: x-my-test: myTest

Actual results

The header is being upper cased for the first char resulting in: X-my-test: myTest