Skip to content

Added gzip decompression support to elastic4s-http#1473

Merged
sksamuel merged 2 commits into
Philippus:masterfrom
ilyshav:content-encoding-bug
Aug 1, 2018
Merged

Added gzip decompression support to elastic4s-http#1473
sksamuel merged 2 commits into
Philippus:masterfrom
ilyshav:content-encoding-bug

Conversation

@ilyshav
Copy link
Copy Markdown
Contributor

@ilyshav ilyshav commented Aug 1, 2018

Resolves #1472

@sksamuel sksamuel merged commit 5d026f5 into Philippus:master Aug 1, 2018
@sksamuel
Copy link
Copy Markdown
Collaborator

sksamuel commented Aug 1, 2018

👍

@ilyshav ilyshav deleted the content-encoding-bug branch August 1, 2018 14:21
@yanns
Copy link
Copy Markdown
Contributor

yanns commented Aug 6, 2018

Any documentation on how to activate this?

@ilyshav
Copy link
Copy Markdown
Contributor Author

ilyshav commented Aug 7, 2018

@yanns You have to add Accept-Encoding: gzip header.
I did it with httpClientConfigCallback:

import scala.collection.JavaConverters._

RestClient
      .builder(new HttpHost("localhost", 9200))
      .setHttpClientConfigCallback((httpClientBuilder: HttpAsyncClientBuilder) => {
        httpClientBuilder.setDefaultHeaders(List(new BasicHeader("Accept-Encoding", "gzip")).asJava)
      }).build

Also gzip compression must be enabled in Elastic config:
http.compression: true

@yanns
Copy link
Copy Markdown
Contributor

yanns commented Aug 7, 2018

Thx a lot.
Should we consider activating that per default?
It will only be used the elastic config enables that, right?

@ilyshav
Copy link
Copy Markdown
Contributor Author

ilyshav commented Aug 8, 2018

Should we consider activating that per default?

I think we should not enable gzip by default, because this give some profit only is some cases - when Elastic's responses are huge or network perfomance isn't good, but when responses are small, compression will only waste CPU resources , as far as I know.

It will only be used the elastic config enables that, right?

I think if Elastic compression will be disabled and we pass accept-encoding header, Elastic will just send plain text responses, so it will work anyway, but this is only my assumption, I'm not checked it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants