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

Commit 9ee2b11

Browse files
committed
Merge branch 'hotfix/199'
Close #199 Fix #91
2 parents 5176d6f + d3ba68c commit 9ee2b11

File tree

3 files changed

+33
-1
lines changed

3 files changed

+33
-1
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ All notable changes to this project will be documented in this file, in reverse
3636

3737
- [#198](https://github.com/zendframework/zend-http/pull/198) fixes various issues with `Proxy` adapter.
3838

39+
- [#199](https://github.com/zendframework/zend-http/pull/199) fixes saving resource to the file when streaming while client supports compression. Before, incorrectly, compressed resource was saved into the file.
40+
3941
## 2.10.0 - 2019-02-19
4042

4143
### Added

src/Client.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1184,7 +1184,7 @@ protected function prepareHeaders($body, $uri)
11841184
// Set the Accept-encoding header if not set - depending on whether
11851185
// zlib is available or not.
11861186
if (! $this->getRequest()->getHeaders()->has('Accept-Encoding')) {
1187-
if (function_exists('gzinflate')) {
1187+
if (empty($this->config['outputstream']) && function_exists('gzinflate')) {
11881188
$headers['Accept-Encoding'] = 'gzip, deflate';
11891189
} else {
11901190
$headers['Accept-Encoding'] = 'identity';

test/ClientTest.php

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@
1212
use ReflectionMethod;
1313
use Zend\Http\Client;
1414
use Zend\Http\Client\Adapter\AdapterInterface;
15+
use Zend\Http\Client\Adapter\Curl;
16+
use Zend\Http\Client\Adapter\Proxy;
17+
use Zend\Http\Client\Adapter\Socket;
1518
use Zend\Http\Client\Adapter\Test;
1619
use Zend\Http\Client\Exception as ClientException;
1720
use Zend\Http\Cookies;
@@ -607,4 +610,31 @@ public function testSetCookieAcceptOnlyArray()
607610
$this->expectExceptionMessage('Invalid cookies passed as parameter, it must be an array');
608611
$client->setCookies(new SetCookie('name', 'value'));
609612
}
613+
614+
/**
615+
* @return AdapterInterface[]
616+
*/
617+
public function adapterWithStreamSupport()
618+
{
619+
yield 'curl' => [new Curl()];
620+
yield 'proxy' => [new Proxy()];
621+
yield 'socket' => [new Socket()];
622+
}
623+
624+
/**
625+
* @dataProvider adapterWithStreamSupport
626+
*/
627+
public function testStreamCompression(AdapterInterface $adapter)
628+
{
629+
$tmpFile = tempnam(sys_get_temp_dir(), 'stream');
630+
631+
$client = new Client('https://www.gnu.org/licenses/gpl-3.0.txt');
632+
$client->setAdapter($adapter);
633+
$client->setStream($tmpFile);
634+
$client->send();
635+
636+
$response = $client->getResponse();
637+
638+
self::assertSame($response->getBody(), file_get_contents($tmpFile));
639+
}
610640
}

0 commit comments

Comments
 (0)