Class InflatingAsyncDataConsumer
java.lang.Object
org.apache.hc.client5.http.async.methods.InflatingAsyncDataConsumer
- All Implemented Interfaces:
org.apache.hc.core5.http.nio.AsyncDataConsumer, org.apache.hc.core5.http.nio.ResourceHolder
public final class InflatingAsyncDataConsumer
extends Object
implements org.apache.hc.core5.http.nio.AsyncDataConsumer
Streaming, non-blocking AsyncDataConsumer that transparently
inflates a response whose Content-Encoding is deflate.
The decoded bytes are pushed straight to the wrapped downstream consumer
while honouring reactor back-pressure.
The implementation understands both formats that exist “in the wild”: the raw DEFLATE stream (RFC 1951) and the zlib-wrapped variant (RFC 1950). If the caller does not specify which one to expect, the first two bytes of the stream are inspected and the proper decoder is chosen automatically.
No InputStream/OutputStream buffering is used; memory
footprint is bounded and suitable for very large payloads.
- Since:
- 5.6
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final AtomicBooleanprivate final org.apache.hc.core5.http.nio.AsyncDataConsumerprivate booleanprivate Inflaterprivate final Booleanprivate final byte[] -
Constructor Summary
ConstructorsConstructorDescriptionInflatingAsyncDataConsumer(org.apache.hc.core5.http.nio.AsyncDataConsumer downstream, Boolean nowrapHint) -
Method Summary
Modifier and TypeMethodDescriptionvoidconsume(ByteBuffer src) voidvoidvoidupdateCapacity(org.apache.hc.core5.http.nio.CapacityChannel ch)
-
Field Details
-
downstream
private final org.apache.hc.core5.http.nio.AsyncDataConsumer downstream -
nowrapHint
-
inflater
-
formatChosen
private boolean formatChosen -
out
private final byte[] out -
closed
-
-
Constructor Details
-
InflatingAsyncDataConsumer
public InflatingAsyncDataConsumer(org.apache.hc.core5.http.nio.AsyncDataConsumer downstream, Boolean nowrapHint)
-
-
Method Details
-
updateCapacity
- Specified by:
updateCapacityin interfaceorg.apache.hc.core5.http.nio.AsyncDataConsumer- Throws:
IOException
-
consume
- Specified by:
consumein interfaceorg.apache.hc.core5.http.nio.AsyncDataConsumer- Throws:
IOException
-
streamEnd
public void streamEnd(List<? extends org.apache.hc.core5.http.Header> trailers) throws org.apache.hc.core5.http.HttpException, IOException - Specified by:
streamEndin interfaceorg.apache.hc.core5.http.nio.AsyncDataConsumer- Throws:
org.apache.hc.core5.http.HttpExceptionIOException
-
releaseResources
public void releaseResources()- Specified by:
releaseResourcesin interfaceorg.apache.hc.core5.http.nio.ResourceHolder
-