Class InflatingZstdDataConsumer

  • All Implemented Interfaces:
    org.apache.hc.core5.http.nio.AsyncDataConsumer, org.apache.hc.core5.http.nio.ResourceHolder

    public final class InflatingZstdDataConsumer
    extends java.lang.Object
    implements org.apache.hc.core5.http.nio.AsyncDataConsumer
    AsyncDataConsumer that inflates Zstandard (zstd) content codings.

    This consumer accepts compressed bytes and forwards decompressed data to a downstream AsyncDataConsumer. It is intended to be installed by the client execution chain when a response carries Content-Encoding: zstd. Applications normally do not instantiate it directly—enable content compression (default) and let ContentCompressionAsyncExec wire it automatically.

    Behavior

    • Streams decompression as data arrives; does not require the full message in memory.
    • Updates the downstream with plain bytes; the client removes the original Content-Encoding and related headers.
    • On malformed input it throws an IOException with a descriptive message.
    • releaseResources() must be called to free native resources.
    Since:
    5.6
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private java.util.concurrent.atomic.AtomicBoolean closed  
      private com.github.luben.zstd.ZstdDecompressCtx dctx  
      private org.apache.hc.core5.http.nio.AsyncDataConsumer downstream  
      private static int IN_BUF  
      private java.nio.ByteBuffer inDirect  
      private static int OUT_BUF  
      private java.nio.ByteBuffer outDirect  
    • Constructor Summary

      Constructors 
      Constructor Description
      InflatingZstdDataConsumer​(org.apache.hc.core5.http.nio.AsyncDataConsumer downstream)  
    • 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 c)  
      • 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
      • dctx

        private final com.github.luben.zstd.ZstdDecompressCtx dctx
      • inDirect

        private final java.nio.ByteBuffer inDirect
      • outDirect

        private final java.nio.ByteBuffer outDirect
      • closed

        private final java.util.concurrent.atomic.AtomicBoolean closed
    • Constructor Detail

      • InflatingZstdDataConsumer

        public InflatingZstdDataConsumer​(org.apache.hc.core5.http.nio.AsyncDataConsumer downstream)
    • Method Detail

      • updateCapacity

        public void updateCapacity​(org.apache.hc.core5.http.nio.CapacityChannel c)
                            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