This repository was archived by the owner on Jan 30, 2020. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +31
-1
lines changed Expand file tree Collapse file tree 2 files changed +31
-1
lines changed Original file line number Diff line number Diff 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 ' ;
Original file line number Diff line number Diff line change 1212use ReflectionMethod ;
1313use Zend \Http \Client ;
1414use 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 ;
1518use Zend \Http \Client \Adapter \Test ;
1619use Zend \Http \Client \Exception as ClientException ;
1720use 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}
You can’t perform that action at this time.
0 commit comments