Class DeflatingGzipEntityProducer

  • All Implemented Interfaces:
    org.apache.hc.core5.http.EntityDetails, org.apache.hc.core5.http.nio.AsyncDataProducer, org.apache.hc.core5.http.nio.AsyncEntityProducer, org.apache.hc.core5.http.nio.ResourceHolder

    public final class DeflatingGzipEntityProducer
    extends java.lang.Object
    implements org.apache.hc.core5.http.nio.AsyncEntityProducer
    Streams an AsyncEntityProducer through raw DEFLATE and wraps the result in a valid GZIP container.

    Memory usage is bounded (8 KiB buffers) and back-pressure from the I/O reactor is honoured.

    Since:
    5.6
    • Field Detail

      • delegate

        private final org.apache.hc.core5.http.nio.AsyncEntityProducer delegate
      • crc

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

        private final java.util.zip.Deflater deflater
      • in

        private final byte[] in
      • outBuf

        private final java.nio.ByteBuffer outBuf
      • headerSent

        private boolean headerSent
      • finished

        private boolean finished
      • uncompressed

        private long uncompressed
      • released

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

      • DeflatingGzipEntityProducer

        public DeflatingGzipEntityProducer​(org.apache.hc.core5.http.nio.AsyncEntityProducer delegate)
    • Method Detail

      • isRepeatable

        public boolean isRepeatable()
        Specified by:
        isRepeatable in interface org.apache.hc.core5.http.nio.AsyncEntityProducer
      • getContentLength

        public long getContentLength()
        Specified by:
        getContentLength in interface org.apache.hc.core5.http.EntityDetails
      • getContentType

        public java.lang.String getContentType()
        Specified by:
        getContentType in interface org.apache.hc.core5.http.EntityDetails
      • getContentEncoding

        public java.lang.String getContentEncoding()
        Specified by:
        getContentEncoding in interface org.apache.hc.core5.http.EntityDetails
      • isChunked

        public boolean isChunked()
        Specified by:
        isChunked in interface org.apache.hc.core5.http.EntityDetails
      • getTrailerNames

        public java.util.Set<java.lang.String> getTrailerNames()
        Specified by:
        getTrailerNames in interface org.apache.hc.core5.http.EntityDetails
      • available

        public int available()
        Specified by:
        available in interface org.apache.hc.core5.http.nio.AsyncDataProducer
      • produce

        public void produce​(org.apache.hc.core5.http.nio.DataStreamChannel chan)
                     throws java.io.IOException
        Specified by:
        produce in interface org.apache.hc.core5.http.nio.AsyncDataProducer
        Throws:
        java.io.IOException
      • deflateToOut

        private void deflateToOut()
      • flushOut

        private void flushOut​(org.apache.hc.core5.http.nio.DataStreamChannel chan)
                       throws java.io.IOException
        Throws:
        java.io.IOException
      • failed

        public void failed​(java.lang.Exception cause)
        Specified by:
        failed in interface org.apache.hc.core5.http.nio.AsyncEntityProducer
      • releaseResources

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