You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@hc.apache.org by "Siqi Li (JIRA)" <ji...@apache.org> on 2019/02/11 23:26:00 UTC

[jira] [Updated] (HTTPASYNC-148) ResponseContentEncoding HttpResponseInterceptor not being respected

     [ https://issues.apache.org/jira/browse/HTTPASYNC-148?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Siqi Li updated HTTPASYNC-148:
------------------------------
    Summary: ResponseContentEncoding HttpResponseInterceptor not being respected  (was: HttpResponseInterceptor not being respected)

> ResponseContentEncoding HttpResponseInterceptor not being respected
> -------------------------------------------------------------------
>
>                 Key: HTTPASYNC-148
>                 URL: https://issues.apache.org/jira/browse/HTTPASYNC-148
>             Project: HttpComponents HttpAsyncClient
>          Issue Type: Bug
>    Affects Versions: 4.1.4
>         Environment: Windows 10, Oracle JDK 1.8.0_161
>            Reporter: Siqi Li
>            Priority: Major
>
> Here's my code snippet:
> {code:java}
> import java.io.ByteArrayInputStream;
> import java.util.zip.GZIPInputStream;
> import org.apache.commons.io.IOUtils;
> import org.apache.http.HttpResponse;
> import org.apache.http.client.methods.HttpGet;
> import org.apache.http.client.protocol.RequestAcceptEncoding;
> import org.apache.http.client.protocol.ResponseContentEncoding;
> import org.apache.http.impl.nio.client.CloseableHttpAsyncClient;
> import org.apache.http.impl.nio.client.HttpAsyncClients;
> import org.apache.http.util.EntityUtils;
> public class Issue20190211 {
> 	public static void main(String[] args) throws Exception {
> 		try (CloseableHttpAsyncClient client = HttpAsyncClients.custom()
> 				.addInterceptorFirst(new RequestAcceptEncoding())
> 				.addInterceptorFirst(new ResponseContentEncoding())
> 				.build()) {
> 			client.start();
> 			final HttpResponse response = client.execute(
> 					new HttpGet("http://example.com"), null).get();
> 			final byte[] respBytes = EntityUtils.toByteArray(response.getEntity());
> 			System.out.println(new String(respBytes, "UTF-8")); // Prints gibberish
> 			final String decompressed = IOUtils.toString(
> 					new GZIPInputStream(new ByteArrayInputStream(respBytes)), "UTF-8");
> 			System.out.println(decompressed); // This gives me the correct result
> 		}
> 	}
> }
> {code}
> What this looks like to me is that the HttpRequestInterceptor is working, since the server is responding with gzipped content, but the HttpResponseInterceptor is not, since I still have to manually decompress the content.
>  



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org