Top Description Inners Fields Constructors Methods
org.eclipse.jetty.http

public Class GZIPContentDecoder

extends Object
implements Destroyable
Class Inheritance
All Implemented Interfaces
org.eclipse.jetty.util.component.Destroyable
Imports
java.nio.ByteBuffer, java.util.ArrayList, .List, java.util.zip.DataFormatException, .Inflater, .ZipException, org.eclipse.jetty.io.ByteBufferPool, .RetainableByteBuffer, org.eclipse.jetty.util.BufferUtil, org.eclipse.jetty.util.component.Destroyable, org.eclipse.jetty.util.compression.InflaterPool

Decoder for the "gzip" content encoding.

This decoder inflates gzip compressed data, and has been optimized for async usage with minimal data copies.

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static enum

Field Summary

Modifier and TypeField and Description
private final int
private byte
private RetainableByteBuffer
private final List<RetainableByteBuffer>
private Inflater
private CompressionPool<Inflater>.Entry
private final ByteBufferPool
private int
private GZIPContentDecoder.State
private long
private static final long

Constructor Summary

AccessConstructor and Description
public
public
GZIPContentDecoder(int bufferSize)

public
GZIPContentDecoder(ByteBufferPool byteBufferPool, int bufferSize)

public
GZIPContentDecoder(InflaterPool inflaterPool, ByteBufferPool byteBufferPool, int bufferSize)

Method Summary

Modifier and TypeMethod and Description
public RetainableByteBuffer
acquire(int
capacity of the ByteBuffer to acquire
capacity
)

Returns: a heap buffer of the configured capacity either from the pool or freshly allocated.

public RetainableByteBuffer

Returns:

a buffer containing inflated data.
decode
(ByteBuffer
the buffer containing compressed data.
compressed
)

Inflates compressed data from a buffer.

protected void
decodeChunks(ByteBuffer
the buffer of compressed data to inflate
compressed
)

Inflates compressed data.

protected boolean

Returns:

false if inflating should continue, or true if the call to decodeChunks(ByteBuffer) or decode(ByteBuffer) should return, allowing to consume the inflated chunk and apply backpressure
decodedChunk
(RetainableByteBuffer
the inflated chunk of data
chunk
)

Called when a chunk of data is inflated.

public void
public boolean
private void
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

_bufferSizeback to summary
private final int _bufferSize
_flagsback to summary
private byte _flags
_inflatedback to summary
private RetainableByteBuffer _inflated
_inflatedsback to summary
private final List<RetainableByteBuffer> _inflateds
_inflaterback to summary
private Inflater _inflater
_inflaterEntryback to summary
private CompressionPool<Inflater>.Entry _inflaterEntry
_poolback to summary
private final ByteBufferPool _pool
_sizeback to summary
private int _size
_stateback to summary
private GZIPContentDecoder.State _state
_valueback to summary
private long _value
UINT_MAXback to summary
private static final long UINT_MAX

Constructor Detail

GZIPContentDecoderback to summary
public GZIPContentDecoder()
GZIPContentDecoderback to summary
public GZIPContentDecoder(int bufferSize)
GZIPContentDecoderback to summary
public GZIPContentDecoder(ByteBufferPool byteBufferPool, int bufferSize)
GZIPContentDecoderback to summary
public GZIPContentDecoder(InflaterPool inflaterPool, ByteBufferPool byteBufferPool, int bufferSize)

Method Detail

acquireback to summary
public RetainableByteBuffer acquire(int capacity)
Parameters
capacity:int

capacity of the ByteBuffer to acquire

Returns:RetainableByteBuffer

a heap buffer of the configured capacity either from the pool or freshly allocated.

decodeback to summary
public RetainableByteBuffer decode(ByteBuffer compressed)

Inflates compressed data from a buffer.

The RetainableByteBuffer returned by this method must be released via RetainableByteBuffer#release().

This method may fully consume the input buffer, but return only a chunk of the inflated bytes, to allow applications to consume the inflated chunk before performing further inflation, applying backpressure. In this case, this method should be invoked again with the same input buffer (even if it's already fully consumed) and that will produce another chunk of inflated bytes. Termination happens when the input buffer is fully consumed, and the returned buffer is empty.

See decodedChunk(RetainableByteBuffer) to perform inflating in a non-blocking way that allows to apply backpressure.

Parameters
compressed:ByteBuffer

the buffer containing compressed data.

Returns:RetainableByteBuffer

a buffer containing inflated data.

decodeChunksback to summary
protected void decodeChunks(ByteBuffer compressed)

Inflates compressed data.

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

Parameters
compressed:ByteBuffer

the buffer of compressed data to inflate

decodedChunkback to summary
protected boolean decodedChunk(RetainableByteBuffer 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 inflated chunks individually and return true from this method to prevent further inflation until a subsequent call to decode(ByteBuffer) or decodeChunks(ByteBuffer) is made.

Parameters
chunk:RetainableByteBuffer

the inflated chunk of data

Returns:boolean

false if inflating should continue, or true if the call to decodeChunks(ByteBuffer) or decode(ByteBuffer) should return, allowing to consume the inflated chunk and apply backpressure

destroyback to summary
public void destroy()

Implements org.eclipse.jetty.util.component.Destroyable.destroy.

Annotations
@Override
isFinishedback to summary
public boolean isFinished()
resetback to summary
private void reset()
org.eclipse.jetty.http back to summary

private final Enum GZIPContentDecoder.State

extends Enum<GZIPContentDecoder.State>
Class Inheritance

Field Summary

Modifier and TypeField and Description
public static final GZIPContentDecoder.State
public static final GZIPContentDecoder.State
public static final GZIPContentDecoder.State
public static final GZIPContentDecoder.State
public static final GZIPContentDecoder.State
public static final GZIPContentDecoder.State
public static final GZIPContentDecoder.State
public static final GZIPContentDecoder.State
public static final GZIPContentDecoder.State
public static final GZIPContentDecoder.State
public static final GZIPContentDecoder.State
public static final GZIPContentDecoder.State
public static final GZIPContentDecoder.State
public static final GZIPContentDecoder.State
public static final GZIPContentDecoder.State
public static final GZIPContentDecoder.State

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static GZIPContentDecoder.State
public static GZIPContentDecoder.State[]
Inherited from java.lang.Enum:
clonecompareTodescribeConstableequalsfinalizegetDeclaringClasshashCodenameordinaltoStringvalueOf

Field Detail

CMback to summary
public static final GZIPContentDecoder.State CM
COMMENTback to summary
public static final GZIPContentDecoder.State COMMENT
CRCback to summary
public static final GZIPContentDecoder.State CRC
DATAback to summary
public static final GZIPContentDecoder.State DATA
EXTRAback to summary
public static final GZIPContentDecoder.State EXTRA
EXTRA_LENGTHback to summary
public static final GZIPContentDecoder.State EXTRA_LENGTH
FLAGSback to summary
public static final GZIPContentDecoder.State FLAGS
FLGback to summary
public static final GZIPContentDecoder.State FLG
HCRCback to summary
public static final GZIPContentDecoder.State HCRC
IDback to summary
public static final GZIPContentDecoder.State ID
INITIALback to summary
public static final GZIPContentDecoder.State INITIAL
ISIZEback to summary
public static final GZIPContentDecoder.State ISIZE
MTIMEback to summary
public static final GZIPContentDecoder.State MTIME
NAMEback to summary
public static final GZIPContentDecoder.State NAME
OSback to summary
public static final GZIPContentDecoder.State OS
XFLback to summary
public static final GZIPContentDecoder.State XFL

Constructor Detail

Stateback to summary
private State()

Method Detail

valueOfback to summary
public static GZIPContentDecoder.State valueOf(String name)
valuesback to summary
public static GZIPContentDecoder.State[] values()