Class GzipHttpOutputInterceptor
- java.lang.Object
-
- org.eclipse.jetty.server.handler.gzip.GzipHttpOutputInterceptor
-
- All Implemented Interfaces:
HttpOutput.Interceptor
public class GzipHttpOutputInterceptor extends java.lang.Object implements HttpOutput.Interceptor
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private class
GzipHttpOutputInterceptor.GzipBufferCB
private static class
GzipHttpOutputInterceptor.GZState
-
Field Summary
Fields Modifier and Type Field Description private java.nio.ByteBuffer
_buffer
private int
_bufferSize
private HttpChannel
_channel
private java.util.zip.CRC32
_crc
private java.util.zip.Deflater
_deflater
private GzipFactory
_factory
private HttpOutput.Interceptor
_interceptor
private java.util.concurrent.atomic.AtomicReference<GzipHttpOutputInterceptor.GZState>
_state
private boolean
_syncFlush
private HttpField
_vary
private static byte[]
GZIP_HEADER
static Logger
LOG
static HttpField
VARY_ACCEPT_ENCODING
static HttpField
VARY_ACCEPT_ENCODING_USER_AGENT
-
Constructor Summary
Constructors Constructor Description GzipHttpOutputInterceptor(GzipFactory factory, HttpField vary, int bufferSize, HttpChannel channel, HttpOutput.Interceptor next, boolean syncFlush)
GzipHttpOutputInterceptor(GzipFactory factory, HttpField vary, HttpChannel channel, HttpOutput.Interceptor next, boolean syncFlush)
GzipHttpOutputInterceptor(GzipFactory factory, HttpChannel channel, HttpOutput.Interceptor next, boolean syncFlush)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private void
addTrailer()
protected void
commit(java.nio.ByteBuffer content, boolean complete, Callback callback)
private java.lang.String
etagGzip(java.lang.String etag)
HttpOutput.Interceptor
getNextInterceptor()
private void
gzip(java.nio.ByteBuffer content, boolean complete, Callback callback)
boolean
isOptimizedForDirectBuffers()
boolean
mightCompress()
void
noCompression()
void
noCompressionIfPossible()
void
write(java.nio.ByteBuffer content, boolean complete, Callback callback)
Write content.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.eclipse.jetty.server.HttpOutput.Interceptor
resetBuffer
-
-
-
-
Field Detail
-
LOG
public static Logger LOG
-
GZIP_HEADER
private static final byte[] GZIP_HEADER
-
VARY_ACCEPT_ENCODING_USER_AGENT
public static final HttpField VARY_ACCEPT_ENCODING_USER_AGENT
-
VARY_ACCEPT_ENCODING
public static final HttpField VARY_ACCEPT_ENCODING
-
_state
private final java.util.concurrent.atomic.AtomicReference<GzipHttpOutputInterceptor.GZState> _state
-
_crc
private final java.util.zip.CRC32 _crc
-
_factory
private final GzipFactory _factory
-
_interceptor
private final HttpOutput.Interceptor _interceptor
-
_channel
private final HttpChannel _channel
-
_vary
private final HttpField _vary
-
_bufferSize
private final int _bufferSize
-
_syncFlush
private final boolean _syncFlush
-
_deflater
private java.util.zip.Deflater _deflater
-
_buffer
private java.nio.ByteBuffer _buffer
-
-
Constructor Detail
-
GzipHttpOutputInterceptor
public GzipHttpOutputInterceptor(GzipFactory factory, HttpChannel channel, HttpOutput.Interceptor next, boolean syncFlush)
-
GzipHttpOutputInterceptor
public GzipHttpOutputInterceptor(GzipFactory factory, HttpField vary, HttpChannel channel, HttpOutput.Interceptor next, boolean syncFlush)
-
GzipHttpOutputInterceptor
public GzipHttpOutputInterceptor(GzipFactory factory, HttpField vary, int bufferSize, HttpChannel channel, HttpOutput.Interceptor next, boolean syncFlush)
-
-
Method Detail
-
getNextInterceptor
public HttpOutput.Interceptor getNextInterceptor()
- Specified by:
getNextInterceptor
in interfaceHttpOutput.Interceptor
- Returns:
- The next Interceptor in the chain or null if this is the last Interceptor in the chain.
-
isOptimizedForDirectBuffers
public boolean isOptimizedForDirectBuffers()
- Specified by:
isOptimizedForDirectBuffers
in interfaceHttpOutput.Interceptor
- Returns:
- True if the Interceptor is optimized to receive direct
ByteBuffer
s in theHttpOutput.Interceptor.write(ByteBuffer, boolean, Callback)
method. If false is returned, then passing direct buffers may cause inefficiencies.
-
write
public void write(java.nio.ByteBuffer content, boolean complete, Callback callback)
Description copied from interface:HttpOutput.Interceptor
Write content. The response is committed by the first call to write and is closed by a call with last == true. Empty content buffers may be passed to force a commit or close.- Specified by:
write
in interfaceHttpOutput.Interceptor
- Parameters:
content
- The content to be written or an empty buffer.complete
- True if this is the last call to writecallback
- The callback to use to indicateCallback.succeeded()
orCallback.failed(Throwable)
.
-
addTrailer
private void addTrailer()
-
gzip
private void gzip(java.nio.ByteBuffer content, boolean complete, Callback callback)
-
commit
protected void commit(java.nio.ByteBuffer content, boolean complete, Callback callback)
-
etagGzip
private java.lang.String etagGzip(java.lang.String etag)
-
noCompression
public void noCompression()
-
noCompressionIfPossible
public void noCompressionIfPossible()
-
mightCompress
public boolean mightCompress()
-
-