Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge branch 'hotfix/2962' into develop

Forward port #2962

Conflicts:
	tests/ZendTest/Http/ClientTest.php
  • Loading branch information...
commit 9ade8e56443c4836e10ac793bfec501ff2e545fd 2 parents a7819d5 + 83e3218
@weierophinney weierophinney authored
Showing with 27 additions and 4 deletions.
  1. +3 −3 library/Zend/Http/Client.php
  2. +24 −1 tests/ZendTest/Http/ClientTest.php
View
6 library/Zend/Http/Client.php
@@ -1068,11 +1068,11 @@ protected function prepareHeaders($body, $uri)
// Set the Accept-encoding header if not set - depending on whether
// zlib is available or not.
- if (! isset($this->headers['accept-encoding'])) {
+ if (!$this->getRequest()->getHeaders()->has('Accept-Encoding')) {
if (function_exists('gzinflate')) {
- $headers['Accept-encoding'] = 'gzip, deflate';
+ $headers['Accept-Encoding'] = 'gzip, deflate';
} else {
- $headers['Accept-encoding'] = 'identity';
+ $headers['Accept-Encoding'] = 'identity';
}
}
View
25 tests/ZendTest/Http/ClientTest.php
@@ -11,7 +11,8 @@
namespace ZendTest\Http;
use Zend\Http\Client;
-use Zend\Http\Exception;
+
+use Zend\Http\Header\AcceptEncoding;
use Zend\Http\Header\SetCookie;
class ClientTest extends \PHPUnit_Framework_TestCase
@@ -101,4 +102,26 @@ public function testCanOverrideArgSeparator()
$client->setArgSeparator(';');
$this->assertEquals(';', $client->getArgSeparator());
}
+
+ public function testClientUsesAcceptEncodingHeaderFromRequestObject()
+ {
+ $client = new Client();
+
+ $client->setAdapter('Zend\Http\Client\Adapter\Test');
+
+ $request = $client->getRequest();
+
+ $acceptEncodingHeader = new AcceptEncoding();
+ $acceptEncodingHeader->addEncoding('foo', 1);
+ $request->getHeaders()->addHeader($acceptEncodingHeader);
+
+ $client->send();
+
+ $rawRequest = $client->getLastRawRequest();
+
+ $this->assertNotContains('Accept-Encoding: gzip, deflate', $rawRequest, null, true);
+ $this->assertNotContains('Accept-Encoding: identity', $rawRequest, null, true);
+
+ $this->assertContains('Accept-Encoding: foo', $rawRequest);
+ }
}
Please sign in to comment.
Something went wrong with that request. Please try again.