Class 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.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

      Fields 
      Modifier and Type Field Description
      private java.util.concurrent.atomic.AtomicBoolean closed  
      private org.apache.hc.core5.http.nio.AsyncDataConsumer downstream  
      private boolean formatChosen  
      private java.util.zip.Inflater inflater  
      private java.lang.Boolean nowrapHint  
      private 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
      void consume​(java.nio.ByteBuffer src)  
      void releaseResources()  
      void streamEnd​(java.util.List<? extends org.apache.hc.core5.http.Header> trailers)  
      void updateCapacity​(org.apache.hc.core5.http.nio.CapacityChannel ch)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • 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
    • Constructor Detail

      • InflatingAsyncDataConsumer

        public InflatingAsyncDataConsumer​(org.apache.hc.core5.http.nio.AsyncDataConsumer downstream,
                                          java.lang.Boolean nowrapHint)
    • Method Detail

      • updateCapacity

        public void updateCapacity​(org.apache.hc.core5.http.nio.CapacityChannel ch)
                            throws java.io.IOException
        Specified by:
        updateCapacity in interface org.apache.hc.core5.http.nio.AsyncDataConsumer
        Throws:
        java.io.IOException
      • consume

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

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