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

All headers are case insensitive and should be treated as such to pre… #53

Closed
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
4 changes: 2 additions & 2 deletions src/Client/Adapter/Curl.php
Original file line number Diff line number Diff line change
Expand Up @@ -434,13 +434,13 @@ public function write($method, $uri, $httpVersion = 1.1, $headers = [], $body =

// cURL automatically decodes chunked-messages, this means we have to
// disallow the Zend\Http\Response to do it again.
$responseHeaders = preg_replace("/Transfer-Encoding:\s*chunked\\r\\n/", "", $responseHeaders);
$responseHeaders = preg_replace("/Transfer-Encoding:\s*chunked\\r\\n/i", "", $responseHeaders);

// cURL can automatically handle content encoding; prevent double-decoding from occurring
if (isset($this->config['curloptions'][CURLOPT_ENCODING])
&& '' == $this->config['curloptions'][CURLOPT_ENCODING]
) {
$responseHeaders = preg_replace("/Content-Encoding:\s*gzip\\r\\n/", '', $responseHeaders);
$responseHeaders = preg_replace("/Content-Encoding:\s*gzip\\r\\n/i", '', $responseHeaders);
}

// cURL automatically handles Proxy rewrites, remove the "HTTP/1.0 200 Connection established" string:
Expand Down
25 changes: 25 additions & 0 deletions test/Client/CurlTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -397,4 +397,29 @@ public function testSetCurlOptPostFields()
$this->client->send();
$this->assertEquals('foo=bar', $this->client->getResponse()->getBody());
}

/**
* @group ZF-7683
* @see https://github.com/zendframework/zend-http/pull/53
*
* Note: The headers stored in ZF7683-chunked.php are case insensitive
*/
public function testNoCaseSensitiveHeaderName()
{
$this->client->setUri($this->baseuri . 'ZF7683-chunked.php');

$adapter = new Adapter\Curl();
$adapter->setOptions([
'curloptions' => [
CURLOPT_ENCODING => '',
],
]);
$this->client->setAdapter($adapter);
$this->client->setMethod('GET');
$this->client->send();

$headers = $this->client->getResponse()->getHeaders();
$this->assertFalse($headers->has('Transfer-Encoding'));
$this->assertFalse($headers->has('Content-Encoding'));
}
}
4 changes: 4 additions & 0 deletions test/Client/_files/ZF7683-chunked.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?php
// intentional use of case-insensitive header name
header("Transfer-encoding: chunked");
header("content-encoding: gzip");