[ 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-unsubscr...@hc.apache.org For additional commands, e-mail: dev-h...@hc.apache.org