Class GZIPContentDecoder

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

    public class GZIPContentDecoder
    extends java.lang.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.

    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.nio.ByteBuffer acquire​(int capacity)  
      java.nio.ByteBuffer decode​(java.nio.ByteBuffer compressed)
      Inflate compressed data from a buffer.
      protected void decodeChunks​(java.nio.ByteBuffer compressed)
      Inflate compressed data.
      protected boolean decodedChunk​(java.nio.ByteBuffer chunk)
      Called when a chunk of data is inflated.
      void destroy()  
      boolean isFinished()  
      void release​(java.nio.ByteBuffer buffer)
      Release an allocated buffer.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • 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 java.nio.ByteBuffer decode​(java.nio.ByteBuffer compressed)
        Inflate compressed data from a buffer.
        Parameters:
        compressed - Buffer containing compressed data.
        Returns:
        Buffer containing inflated data.
      • decodedChunk

        protected boolean decodedChunk​(java.nio.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​(java.nio.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 java.nio.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​(java.nio.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.