|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.eclipse.jetty.util.component.AbstractLifeCycle
org.eclipse.jetty.util.component.AggregateLifeCycle
org.eclipse.jetty.server.handler.AbstractHandler
org.eclipse.jetty.server.handler.AbstractHandlerContainer
org.eclipse.jetty.server.handler.HandlerWrapper
org.eclipse.jetty.server.handler.GzipHandler
public class GzipHandler
GZIP Handler This handler will gzip the content of a response if:
minGzipSize
initParameter or the minGzipSize is 0(default)mimeTypes
initParameter or if no mimeTypes are defined the
content-type is not "application/gzip"
Compressing the content can greatly improve the network bandwidth usage, but at a cost of memory and CPU cycles. If this handler is used for static content,
then use of efficient direct NIO may be prevented, thus use of the gzip mechanism of the org.eclipse.jetty.servlet.DefaultServlet
is advised instead.
Nested Class Summary |
---|
Nested classes/interfaces inherited from class org.eclipse.jetty.util.component.AbstractLifeCycle |
---|
AbstractLifeCycle.AbstractLifeCycleListener |
Nested classes/interfaces inherited from interface org.eclipse.jetty.util.component.LifeCycle |
---|
LifeCycle.Listener |
Field Summary | |
---|---|
protected int |
_bufferSize
|
protected java.util.Set<java.lang.String> |
_excluded
|
protected java.util.Set<java.lang.String> |
_mimeTypes
|
protected int |
_minGzipSize
|
Fields inherited from class org.eclipse.jetty.server.handler.HandlerWrapper |
---|
_handler |
Fields inherited from class org.eclipse.jetty.util.component.AbstractLifeCycle |
---|
_listeners, FAILED, RUNNING, STARTED, STARTING, STOPPED, STOPPING |
Constructor Summary | |
---|---|
GzipHandler()
Instantiates a new gzip handler. |
Method Summary | |
---|---|
int |
getBufferSize()
Get the buffer size. |
java.util.Set<java.lang.String> |
getExcluded()
Get the excluded user agents. |
java.util.Set<java.lang.String> |
getMimeTypes()
Get the mime types. |
int |
getMinGzipSize()
Get the minimum reponse size. |
void |
handle(java.lang.String target,
Request baseRequest,
javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
Handle a request. |
protected CompressedResponseWrapper |
newGzipResponseWrapper(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
Allows derived implementations to replace ResponseWrapper implementation. |
protected java.io.PrintWriter |
newWriter(java.io.OutputStream out,
java.lang.String encoding)
Allows derived implementations to replace PrintWriter implementation. |
void |
setBufferSize(int bufferSize)
Set the buffer size. |
void |
setExcluded(java.util.Set<java.lang.String> excluded)
Set the excluded user agents. |
void |
setExcluded(java.lang.String excluded)
Set the excluded user agents. |
void |
setMimeTypes(java.util.Set<java.lang.String> mimeTypes)
Set the mime types. |
void |
setMimeTypes(java.lang.String mimeTypes)
Set the mime types. |
void |
setMinGzipSize(int minGzipSize)
Set the minimum reponse size. |
Methods inherited from class org.eclipse.jetty.server.handler.HandlerWrapper |
---|
destroy, doStart, doStop, expandChildren, getHandler, getHandlers, getNestedHandlerByClass, setHandler, setServer |
Methods inherited from class org.eclipse.jetty.server.handler.AbstractHandlerContainer |
---|
dump, expandHandler, findContainerOf, getChildHandlerByClass, getChildHandlers, getChildHandlersByClass |
Methods inherited from class org.eclipse.jetty.server.handler.AbstractHandler |
---|
dumpThis, getServer |
Methods inherited from class org.eclipse.jetty.util.component.AggregateLifeCycle |
---|
addBean, addBean, contains, dump, dump, dump, dump, dumpObject, dumpStdErr, getBean, getBeans, getBeans, isManaged, manage, removeBean, removeBeans, unmanage |
Methods inherited from class org.eclipse.jetty.util.component.AbstractLifeCycle |
---|
addLifeCycleListener, getState, getState, isFailed, isRunning, isStarted, isStarting, isStopped, isStopping, removeLifeCycleListener, start, stop |
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.util.component.LifeCycle |
---|
addLifeCycleListener, isFailed, isRunning, isStarted, isStarting, isStopped, isStopping, removeLifeCycleListener, start, stop |
Field Detail |
---|
protected java.util.Set<java.lang.String> _mimeTypes
protected java.util.Set<java.lang.String> _excluded
protected int _bufferSize
protected int _minGzipSize
Constructor Detail |
---|
public GzipHandler()
Method Detail |
---|
public java.util.Set<java.lang.String> getMimeTypes()
public void setMimeTypes(java.util.Set<java.lang.String> mimeTypes)
mimeTypes
- the mime types to setpublic void setMimeTypes(java.lang.String mimeTypes)
mimeTypes
- the mime types to setpublic java.util.Set<java.lang.String> getExcluded()
public void setExcluded(java.util.Set<java.lang.String> excluded)
excluded
- excluded user agents to setpublic void setExcluded(java.lang.String excluded)
excluded
- excluded user agents to setpublic int getBufferSize()
public void setBufferSize(int bufferSize)
bufferSize
- buffer size to setpublic int getMinGzipSize()
public void setMinGzipSize(int minGzipSize)
minGzipSize
- minimum reponse sizepublic void handle(java.lang.String target, Request baseRequest, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws java.io.IOException, javax.servlet.ServletException
Handler
handle
in interface Handler
handle
in class HandlerWrapper
target
- The target of the request - either a URI or a name.baseRequest
- The original unwrapped request object.request
- The request either as the Request
object or a wrapper of that request. The AbstractHttpConnection.getCurrentConnection()
method can be used access the Request object if required.response
- The response as the Response
object or a wrapper of that request. The AbstractHttpConnection.getCurrentConnection()
method can be used access the Response object if required.
java.io.IOException
javax.servlet.ServletException
HandlerWrapper.handle(java.lang.String, org.eclipse.jetty.server.Request, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
protected CompressedResponseWrapper newGzipResponseWrapper(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
request
- the requestresponse
- the response
protected java.io.PrintWriter newWriter(java.io.OutputStream out, java.lang.String encoding) throws java.io.UnsupportedEncodingException
out
- the outencoding
- the encoding
java.io.UnsupportedEncodingException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |