Skip to content

Commit

Permalink
Merge branch 'hotfix/4555'
Browse files Browse the repository at this point in the history
  • Loading branch information
Mike Willbanks committed Jul 23, 2013
2 parents 069851d + 271046b commit a643329
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 0 deletions.
8 changes: 8 additions & 0 deletions library/Zend/Http/Client/Adapter/Curl.php
Original file line number Diff line number Diff line change
Expand Up @@ -427,6 +427,14 @@ public function write($method, $uri, $httpVersion = 1.1, $headers = array(), $bo
$this->response = str_ireplace("Transfer-Encoding: chunked\r\n", '', $this->response);
}

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

// Eliminate multiple HTTP responses.
do {
$parts = preg_split('|(?:\r?\n){2}|m', $this->response, 2);
Expand Down
18 changes: 18 additions & 0 deletions tests/ZendTest/Http/Client/CurlTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -347,4 +347,22 @@ public function testAuthorizeHeader()

$this->assertContains($header, $curlInfo['request_header'], 'Expecting valid basic authorization header');
}

/**
* @group 4555
*/
public function testResponseDoesNotDoubleDecodeGzippedBody()
{
$this->client->setUri($this->baseuri . 'testCurlGzipData.php');
$adapter = new Adapter\Curl();
$adapter->setOptions(array(
'curloptions' => array(
CURLOPT_ENCODING => '',
),
));
$this->client->setAdapter($adapter);
$this->client->setMethod('GET');
$this->client->send();
$this->assertEquals('Success', $this->client->getResponse()->getBody());
}
}
3 changes: 3 additions & 0 deletions tests/ZendTest/Http/Client/_files/testCurlGzipData.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<?php
header('Content-Encoding: gzip');
echo gzcompress('Success');

0 comments on commit a643329

Please sign in to comment.