[
https://issues.apache.org/jira/browse/HTTPCLIENT-2332?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Oleg Kalnichevski resolved HTTPCLIENT-2332.
-------------------------------------------
Resolution: Duplicate
> Example of decompressing async response
> ---------------------------------------
>
> Key: HTTPCLIENT-2332
> URL: https://issues.apache.org/jira/browse/HTTPCLIENT-2332
> Project: HttpComponents HttpClient
> Issue Type: Improvement
> Components: HttpClient (async)
> Affects Versions: 5.3.1
> Reporter: Patrick Barry
> Priority: Major
>
> 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:
> {code:java}
> Future<Message<HttpResponse, byte[]>> execFuture =
> asyncClient.execute(request,
> new BasicResponseConsumer<>(new LimitingEntityConsumer(maxSize,
> maxTotalWaitTimeForResponse, context)),
> null,
> context,
> new ClientCallback(completableFuture, context)
> ); {code}
> *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...
>
> {code:java}
> protected abstract T generateContent( * add decompression code here) throws
> IOException; {code}
> or
> register a response interceptor on async client as:
> {code:java}
> asyncClient.addResponseInterceptorFirst(new Decompressor()) {code}
> or
> register a AsyncExecChainHandler on async client as:
> {code:java}
> .addExecInterceptorLast("decompress", new Decompressor()) {code}
--
This message was sent by Atlassian Jira
(v8.20.10#820010)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]