Class GZIPContentDecoder

  • All Implemented Interfaces:
    org.eclipse.jetty.util.component.Destroyable

    public class GZIPContentDecoder
    extends Object
    implements org.eclipse.jetty.util.component.Destroyable
    Decoder for the "gzip" encoding.

    A decoder that inflates gzip compressed data that has been optimized for async usage with minimal data copies.

    • Constructor Detail

      • GZIPContentDecoder

        public GZIPContentDecoder()
      • GZIPContentDecoder

        public GZIPContentDecoder​(int bufferSize)
      • GZIPContentDecoder

        public GZIPContentDecoder​(org.eclipse.jetty.io.ByteBufferPool pool,
                                  int bufferSize)
    • Method Detail

      • decode

        public ByteBuffer decode​(ByteBuffer compressed)
        Inflate compressed data from a buffer.
        Parameters:
        compressed - Buffer containing compressed data.
        Returns:
        Buffer containing inflated data.
      • decodedChunk

        protected boolean decodedChunk​(ByteBuffer chunk)
        Called when a chunk of data is inflated.

        The default implementation aggregates all the chunks into a single buffer returned from decode(ByteBuffer). Derived implementations may choose to consume chunks individually and return false to prevent further inflation until a subsequent call to decode(ByteBuffer) or decodeChunks(ByteBuffer).

        Parameters:
        chunk - The inflated chunk of data
        Returns:
        False if inflating should continue, or True if the call to decodeChunks(ByteBuffer) or decode(ByteBuffer) should return, allowing back pressure of compressed data.
      • decodeChunks

        protected void decodeChunks​(ByteBuffer compressed)
        Inflate compressed data.

        Inflation continues until the compressed block end is reached, there is no more compressed data or a call to decodedChunk(ByteBuffer) returns true.

        Parameters:
        compressed - Buffer of compressed data to inflate
      • destroy

        public void destroy()
        Specified by:
        destroy in interface org.eclipse.jetty.util.component.Destroyable
      • isFinished

        public boolean isFinished()
      • acquire

        public ByteBuffer acquire​(int capacity)
        Parameters:
        capacity - capacity capacity of the allocated ByteBuffer
        Returns:
        An indirect buffer of the configured buffersize either from the pool or freshly allocated.
      • release

        public void release​(ByteBuffer buffer)
        Release an allocated buffer.

        This method will called ByteBufferPool.release(ByteBuffer) if a buffer pool has been configured. This method should be called once for all buffers returned from decode(ByteBuffer) or passed to decodedChunk(ByteBuffer).

        Parameters:
        buffer - The buffer to release.