-
Notifications
You must be signed in to change notification settings - Fork 982
Description
Summary of problem or feature request
ClientBuilder::build()
adds an Accept-Encoding:gzip
header when elasticCloudId
is provided but does not handle decompression of gzip compressed responses.
We're using Symfony\Component\HttpClient\HttplugClient
as asyncHttpClient
which adds gzip by default but does not handle decoding when the Accept-Encoding
header is explicitly set.
As per Symfony HTTPClient maintainer:
you explicitly send the request with the "accept-encoding" header. When you do this, you disable transparent compression and you opt-in for explicit compression, which means it's now your job to effectively decompress.
Don't send the header if that's not what you want.
symfony/symfony#34238 (comment)
Thus the Elastic Client should either handle decompressen (and check whether the required zlib
PHP extension is loaded) or the Elastic Client should leave responsibility for decompression to the Psr\Http\Client\ClientInterface
implementation and not set the header at all, we prefer the latter.
Code snippet of problem
if (!empty($this->cloudId)) {
$transport->setHeader('Accept-Encoding', 'gzip');
}
And in Symfony HTTPClient:
$this->inflate = !isset($options['normalized_headers']['accept-encoding']); // This prevents decompression
System details
- PHP version: 8.1.8
- ES-PHP client version: 8.3.2
- Elasticsearch version: 7.15.2