diff --git a/.ci/jobs/elastic+enterprise-search-php+8.5.yml b/.ci/jobs/elastic+enterprise-search-php+8.7.yml similarity index 56% rename from .ci/jobs/elastic+enterprise-search-php+8.5.yml rename to .ci/jobs/elastic+enterprise-search-php+8.7.yml index df3e581..0424f65 100644 --- a/.ci/jobs/elastic+enterprise-search-php+8.5.yml +++ b/.ci/jobs/elastic+enterprise-search-php+8.7.yml @@ -1,12 +1,12 @@ --- - job: - name: elastic+enterprise-search-php+8.5 - display-name: 'elastic / enterprise-search-php # 8.5' - description: Testing the enterprise-search-php 8.5 branch. + name: elastic+enterprise-search-php+8.7 + display-name: 'elastic / enterprise-search-php # 8.7' + description: Testing the enterprise-search-php 8.7 branch. parameters: - string: name: branch_specifier - default: refs/heads/8.5 + default: refs/heads/8.7 description: the Git branch specifier to build (<branchName>, <tagName>, <commitId>, etc.) triggers: diff --git a/CHANGELOG.md b/CHANGELOG.md index a2bab9f..3be1ea3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## 8.7.1 (2023-06-01) + +- Removes Accept-Encoding (gzip) header when using Symfony HTTP client + ## 8.7.0 (2023-04-04) Release compatible with Enterprise Search, App Search and Workplace Search 8.7. diff --git a/composer.json b/composer.json index e3f9b4f..5cbb24e 100644 --- a/composer.json +++ b/composer.json @@ -22,7 +22,8 @@ "require-dev": { "phpunit/phpunit": "^9.5", "guzzlehttp/guzzle": "^7.0", - "phpstan/phpstan": "^1.8" + "phpstan/phpstan": "^1.8", + "symfony/http-client": "^6.0" }, "suggest": { "guzzlehttp/guzzle": "We suggest to use Guzzle as PSR-18 HTTP library" diff --git a/src/Client.php b/src/Client.php index 98b23da..9f6bb7f 100644 --- a/src/Client.php +++ b/src/Client.php @@ -24,7 +24,7 @@ class Client { - const VERSION = '8.6.0'; + const VERSION = '8.7.0'; private array $config = []; @@ -110,7 +110,9 @@ private function initTransport(Transport $transport, array $config): void if (!isset($config['meta-header']) || $config['meta-header']) { $transport->setElasticMetaHeader('ent', self::VERSION); } - $transport->setHeader('Accept-Encoding', 'gzip'); + if (!$this->isSymfonyHttpClient($transport)) { + $transport->setHeader('Accept-Encoding', 'gzip'); + } } /** @@ -185,4 +187,15 @@ private function setAuthentication(Transport $transport, array $config, string $ 'You need to use an authentication method: username and password, token or apiKey' ); } + + private function isSymfonyHttpClient(Transport $transport): bool + { + if (false !== strpos(get_class($transport->getClient()), 'Symfony\Component\HttpClient')) { + return true; + } + if (false !== strpos(get_class($transport->getAsyncClient()), 'Symfony\Component\HttpClient')) { + return true; + } + return false; + } } \ No newline at end of file