Class InflatingGzipDataConsumer

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

    public final class InflatingGzipDataConsumer
    extends java.lang.Object
    implements org.apache.hc.core5.http.nio.AsyncDataConsumer
    Streaming AsyncDataConsumer that inflates Content-Encoding: gzip. It parses the GZIP header on the fly, passes the deflated body through a Inflater and verifies CRC + length trailer.

    The implementation is fully non-blocking and honours back-pressure.

    Since:
    5.6
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private java.util.concurrent.atomic.AtomicBoolean closed  
      private java.util.zip.CRC32 crc  
      private org.apache.hc.core5.http.nio.AsyncDataConsumer downstream  
      private java.io.ByteArrayOutputStream headerBuf  
      private boolean headerDone  
      private java.util.zip.Inflater inflater  
      private byte[] out  
      private static int OUT  
    • Constructor Summary

      Constructors 
      Constructor Description
      InflatingGzipDataConsumer​(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
      • inflater

        private final java.util.zip.Inflater inflater
      • crc

        private final java.util.zip.CRC32 crc
      • out

        private final byte[] out
      • headerBuf

        private final java.io.ByteArrayOutputStream headerBuf
      • headerDone

        private boolean headerDone
      • closed

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

      • InflatingGzipDataConsumer

        public InflatingGzipDataConsumer​(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