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 java.lang.Object implements org.apache.hc.core5.http.nio.AsyncDataConsumerStreaming, non-blocking
AsyncDataConsumerthat transparently inflates a response whoseContent-Encodingisdeflate. 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/OutputStreambuffering is used; memory footprint is bounded and suitable for very large payloads.- Since:
- 5.6
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.concurrent.atomic.AtomicBooleanclosedprivate org.apache.hc.core5.http.nio.AsyncDataConsumerdownstreamprivate booleanformatChosenprivate java.util.zip.Inflaterinflaterprivate java.lang.BooleannowrapHintprivate byte[]out
-
Constructor Summary
Constructors Constructor Description InflatingAsyncDataConsumer(org.apache.hc.core5.http.nio.AsyncDataConsumer downstream, java.lang.Boolean nowrapHint)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidconsume(java.nio.ByteBuffer src)voidreleaseResources()voidstreamEnd(java.util.List<? extends org.apache.hc.core5.http.Header> trailers)voidupdateCapacity(org.apache.hc.core5.http.nio.CapacityChannel ch)
-
-
-
Field Detail
-
downstream
private final org.apache.hc.core5.http.nio.AsyncDataConsumer downstream
-
nowrapHint
private final java.lang.Boolean nowrapHint
-
inflater
private java.util.zip.Inflater inflater
-
formatChosen
private boolean formatChosen
-
out
private final byte[] out
-
closed
private final java.util.concurrent.atomic.AtomicBoolean closed
-
-
Method Detail
-
updateCapacity
public void updateCapacity(org.apache.hc.core5.http.nio.CapacityChannel ch) throws java.io.IOException- Specified by:
updateCapacityin interfaceorg.apache.hc.core5.http.nio.AsyncDataConsumer- Throws:
java.io.IOException
-
consume
public void consume(java.nio.ByteBuffer src) throws java.io.IOException- Specified by:
consumein interfaceorg.apache.hc.core5.http.nio.AsyncDataConsumer- Throws:
java.io.IOException
-
streamEnd
public void streamEnd(java.util.List<? extends org.apache.hc.core5.http.Header> trailers) throws org.apache.hc.core5.http.HttpException, java.io.IOException- Specified by:
streamEndin interfaceorg.apache.hc.core5.http.nio.AsyncDataConsumer- Throws:
org.apache.hc.core5.http.HttpExceptionjava.io.IOException
-
releaseResources
public void releaseResources()
- Specified by:
releaseResourcesin interfaceorg.apache.hc.core5.http.nio.ResourceHolder
-
-