Details
-
Improvement
-
Status: Resolved
-
Major
-
Resolution: Duplicate
-
5.3.1
-
None
-
None
Description
I have scoured the internet trying to find guidance or an example of how to properly decompress an entity while using the async client. What is best practice for wiring in this logic?
We have a CloseableHttpAsyncClient and we are currently executing a request like:
Future<Message<HttpResponse, byte[]>> execFuture = asyncClient.execute(request, new BasicResponseConsumer<>(new LimitingEntityConsumer(maxSize, maxTotalWaitTimeForResponse, context)), null, context, new ClientCallback(completableFuture, context) );
LimitingEntityConsumer [extends BasicAsyncEntityConsumer] keeps track of how many bytes have been read and if we exceed limit, it throws exception. It also throws exception if it is taking too long to read/buffer the response. In the event we have a compressed entity.... what is the best way to handle this? I have code already to decompress the Entity, but should that logic be embedded in an overridden method in LimitingEntityConsumer...
protected abstract T generateContent( * add decompression code here) throws IOException;
or
register a response interceptor on async client as:
asyncClient.addResponseInterceptorFirst(new Decompressor())
or
register a AsyncExecChainHandler on async client as:
.addExecInterceptorLast("decompress", new Decompressor())
Attachments
Issue Links
- duplicates
-
HTTPCLIENT-1822 Support for transparent content decompression
- Open