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

Commit e9fb717

Browse files
committed
Merge branch 'lucian303-fix-case-sensitive-header-handling'
2 parents c3ebd0d + 871dda0 commit e9fb717

File tree

3 files changed

+33
-2
lines changed

3 files changed

+33
-2
lines changed

src/Client/Adapter/Curl.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -434,13 +434,13 @@ public function write($method, $uri, $httpVersion = 1.1, $headers = [], $body =
434434

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

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

446446
// cURL automatically handles Proxy rewrites, remove the "HTTP/1.0 200 Connection established" string:

test/Client/CurlTest.php

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -397,4 +397,31 @@ public function testSetCurlOptPostFields()
397397
$this->client->send();
398398
$this->assertEquals('foo=bar', $this->client->getResponse()->getBody());
399399
}
400+
401+
402+
/**
403+
* @group ZF-7683
404+
* @see https://github.com/zendframework/zend-http/pull/53
405+
*
406+
* Note: The headers stored in ZF7683-chunked.php are case insensitive
407+
*/
408+
public function testNoCaseSensitiveHeaderName()
409+
{
410+
$this->client->setUri($this->baseuri . 'ZF7683-chunked.php');
411+
412+
$adapter = new Adapter\Curl();
413+
$adapter->setOptions([
414+
'curloptions' => [
415+
CURLOPT_ENCODING => '',
416+
],
417+
]);
418+
$this->client->setAdapter($adapter);
419+
$this->client->setMethod('GET');
420+
$this->client->send();
421+
422+
$headers = $this->client->getResponse()->getHeaders();
423+
424+
$this->assertFalse($headers->has('Transfer-Encoding'));
425+
$this->assertFalse($headers->has('Content-Encoding'));
426+
}
400427
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<?php
2+
// intentional use of case-insensitive header name
3+
header("Transfer-encoding: chunked");
4+
header("content-encoding: gzip");

0 commit comments

Comments
 (0)