Class InflatingBrotliDataConsumer
java.lang.Object
org.apache.hc.client5.http.async.methods.InflatingBrotliDataConsumer
- All Implemented Interfaces:
org.apache.hc.core5.http.nio.AsyncDataConsumer, org.apache.hc.core5.http.nio.ResourceHolder
public final class InflatingBrotliDataConsumer
extends Object
implements org.apache.hc.core5.http.nio.AsyncDataConsumer
AsyncDataConsumer that inflates a Brotli-compressed byte stream and forwards
decompressed bytes to a downstream consumer.
Purely async/streaming: no InputStream/OutputStream. Back-pressure from
the I/O reactor is propagated via CapacityChannel. JNI output buffers are copied
into small reusable direct ByteBuffers before handing them to the
downstream consumer (which may retain them).
Implementation notes
Uses Brotli4j’sDecoderJNI.Wrapper. Native resources are released in
releaseResources(). Throws an IOException if the stream is
truncated or corrupted.
Ensure Brotli4jLoader.ensureAvailability() has been
called once at startup; this class also invokes it in a static initializer as a safeguard.
- Since:
- 5.6
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate org.apache.hc.core5.http.nio.CapacityChannelprivate final com.aayushatharva.brotli4j.decoder.DecoderJNI.Wrapperprivate final org.apache.hc.core5.http.nio.AsyncDataConsumer -
Constructor Summary
ConstructorsConstructorDescriptionInflatingBrotliDataConsumer(org.apache.hc.core5.http.nio.AsyncDataConsumer downstream) -
Method Summary
Modifier and TypeMethodDescriptionvoidconsume(ByteBuffer src) private voidpump()voidvoidvoidupdateCapacity(org.apache.hc.core5.http.nio.CapacityChannel capacityChannel)
-
Field Details
-
downstream
private final org.apache.hc.core5.http.nio.AsyncDataConsumer downstream -
decoder
private final com.aayushatharva.brotli4j.decoder.DecoderJNI.Wrapper decoder -
capacity
private volatile org.apache.hc.core5.http.nio.CapacityChannel capacity
-
-
Constructor Details
-
InflatingBrotliDataConsumer
public InflatingBrotliDataConsumer(org.apache.hc.core5.http.nio.AsyncDataConsumer downstream)
-
-
Method Details
-
updateCapacity
public void updateCapacity(org.apache.hc.core5.http.nio.CapacityChannel capacityChannel) throws IOException - 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 IOException, org.apache.hc.core5.http.HttpException - Specified by:
streamEndin interfaceorg.apache.hc.core5.http.nio.AsyncDataConsumer- Throws:
IOExceptionorg.apache.hc.core5.http.HttpException
-
releaseResources
public void releaseResources()- Specified by:
releaseResourcesin interfaceorg.apache.hc.core5.http.nio.ResourceHolder
-
pump
- Throws:
IOException
-