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’s DecoderJNI.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:
  • AsyncDataConsumer
  • CapacityChannel
  • DecoderJNI
  • 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:
      updateCapacity in interface org.apache.hc.core5.http.nio.AsyncDataConsumer
      Throws:
      IOException
    • consume

      public void consume(ByteBuffer src) throws IOException
      Specified by:
      consume in interface org.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:
      streamEnd in interface org.apache.hc.core5.http.nio.AsyncDataConsumer
      Throws:
      IOException
      org.apache.hc.core5.http.HttpException
    • releaseResources

      public void releaseResources()
      Specified by:
      releaseResources in interface org.apache.hc.core5.http.nio.ResourceHolder