On Thu, May 25, 2017 at 11:13 AM, Shaun Elliott <javamonke...@gmail.com> wrote: > The following code works in v4.2.x > > public class RestClientTest { > private static final Executor EXECUTOR = Executor.newInstance(); > > public static void main(String[] args) throws IOException { > Request request = > Request.Get("http://www.google.com/").addHeader("Accept-Encoding", > "gzip"); > Response response = request.execute();// Response > response = EXECUTOR.execute(request); > Header[] headers = response.returnResponse().getAllHeaders(); > for (Header header : headers) { > System.out.println(header); > } > } > } > > > Returned in response headers: > > Content-Encoding: gzip > > > But, if I update my version, to 4.3.x+ it no longer works. It appears based > on this comment: > > https://issues.apache.org/jira/browse/HTTPCLIENT-816?focusedCommentId=13998604&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-13998604 > > That gzip encoding was only available in 4.2.x. Is this the case, or is > there another explanation? Can we get gzip encoding in versions later than > 4.2.x?
Shaun, You can achieve that by using the RequestAcceptEncoding request interceptor, and the ResponseContentEncoding response interceptor. To use interceptors, see the tutorial section 1.4 [1]. Note that the ResponseContentEncoding provides 'transparent' content decompression, and after the content is decompressed you will not see the Content-Encoding header even though the entity may be compressed on the wire. If you are using HttpClients or HttpClientBuilder, the two interceptors should automatically be added for you, unless you explicitly call disableContentCompression or add custom compression handling using setContentDecoderRegistry [2] method. - Bindul [1] http://hc.apache.org/httpcomponents-client-4.5.x/tutorial/html/fundamentals.html#protocol_interceptors [2] http://hc.apache.org/httpcomponents-client-ga/httpclient/apidocs/org/apache/http/impl/client/HttpClientBuilder.html#setContentDecoderRegistry(java.util.Map) > > Thanks, > Shaun Elliott --------------------------------------------------------------------- To unsubscribe, e-mail: httpclient-users-unsubscr...@hc.apache.org For additional commands, e-mail: httpclient-users-h...@hc.apache.org