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 Details

    • downstream

      private final org.apache.hc.core5.http.nio.AsyncDataConsumer downstream
    • nowrapHint

      private final Boolean nowrapHint
    • inflater

      private Inflater inflater
    • formatChosen

      private boolean formatChosen
    • out

      private final byte[] out
    • closed

      private final AtomicBoolean closed
  • Constructor Details

    • InflatingAsyncDataConsumer

      public InflatingAsyncDataConsumer(org.apache.hc.core5.http.nio.AsyncDataConsumer downstream, Boolean nowrapHint)
  • Method Details

    • updateCapacity

      public void updateCapacity(org.apache.hc.core5.http.nio.CapacityChannel ch) 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 org.apache.hc.core5.http.HttpException, IOException
      Specified by:
      streamEnd in interface org.apache.hc.core5.http.nio.AsyncDataConsumer
      Throws:
      org.apache.hc.core5.http.HttpException
      IOException
    • releaseResources

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