org.eclipse.jetty.server.handler
类 GzipHandler

java.lang.Object
  继承者 org.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
所有已实现的接口:
Handler, HandlerContainer, Destroyable, Dumpable, LifeCycle

public class GzipHandler
extends HandlerWrapper

GZIP Handler This handler will gzip the content of a response if:

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.


嵌套类摘要
 
从类 org.eclipse.jetty.util.component.AbstractLifeCycle 继承的嵌套类/接口
AbstractLifeCycle.AbstractLifeCycleListener
 
从接口 org.eclipse.jetty.util.component.LifeCycle 继承的嵌套类/接口
LifeCycle.Listener
 
字段摘要
protected  int _bufferSize
           
protected  Set<String> _excluded
           
protected  Set<String> _mimeTypes
           
protected  int _minGzipSize
           
protected  String _vary
           
 
从类 org.eclipse.jetty.server.handler.HandlerWrapper 继承的字段
_handler
 
从类 org.eclipse.jetty.util.component.AbstractLifeCycle 继承的字段
_listeners, FAILED, RUNNING, STARTED, STARTING, STOPPED, STOPPING
 
构造方法摘要
GzipHandler()
          Instantiates a new gzip handler.
 
方法摘要
 int getBufferSize()
          Get the buffer size.
 Set<String> getExcluded()
          Get the excluded user agents.
 Set<String> getMimeTypes()
          Get the mime types.
 int getMinGzipSize()
          Get the minimum reponse size.
 String getVary()
           
 void handle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response)
          Handle a request.
protected  CompressedResponseWrapper newGzipResponseWrapper(HttpServletRequest request, HttpServletResponse response)
          Allows derived implementations to replace ResponseWrapper implementation.
protected  PrintWriter newWriter(OutputStream out, String encoding)
          Allows derived implementations to replace PrintWriter implementation.
 void setBufferSize(int bufferSize)
          Set the buffer size.
 void setExcluded(Set<String> excluded)
          Set the excluded user agents.
 void setExcluded(String excluded)
          Set the excluded user agents.
 void setMimeTypes(Set<String> mimeTypes)
          Set the mime types.
 void setMimeTypes(String mimeTypes)
          Set the mime types.
 void setMinGzipSize(int minGzipSize)
          Set the minimum reponse size.
 void setVary(String vary)
          Set the value of the Vary header sent with responses that could be compressed.
 
从类 org.eclipse.jetty.server.handler.HandlerWrapper 继承的方法
destroy, doStart, doStop, expandChildren, getHandler, getHandlers, getNestedHandlerByClass, setHandler, setServer
 
从类 org.eclipse.jetty.server.handler.AbstractHandlerContainer 继承的方法
dump, expandHandler, findContainerOf, getChildHandlerByClass, getChildHandlers, getChildHandlersByClass
 
从类 org.eclipse.jetty.server.handler.AbstractHandler 继承的方法
dumpThis, getServer
 
从类 org.eclipse.jetty.util.component.AggregateLifeCycle 继承的方法
addBean, addBean, contains, dump, dump, dump, dump, dumpObject, dumpStdErr, getBean, getBeans, getBeans, isManaged, manage, removeBean, removeBeans, unmanage
 
从类 org.eclipse.jetty.util.component.AbstractLifeCycle 继承的方法
addLifeCycleListener, getState, getState, isFailed, isRunning, isStarted, isStarting, isStopped, isStopping, removeLifeCycleListener, start, stop
 
从类 java.lang.Object 继承的方法
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
从接口 org.eclipse.jetty.util.component.LifeCycle 继承的方法
addLifeCycleListener, isFailed, isRunning, isStarted, isStarting, isStopped, isStopping, removeLifeCycleListener, start, stop
 

字段详细信息

_mimeTypes

protected Set<String> _mimeTypes

_excluded

protected Set<String> _excluded

_bufferSize

protected int _bufferSize

_minGzipSize

protected int _minGzipSize

_vary

protected String _vary
构造方法详细信息

GzipHandler

public GzipHandler()
Instantiates a new gzip handler.

方法详细信息

getMimeTypes

public Set<String> getMimeTypes()
Get the mime types.

返回:
mime types to set

setMimeTypes

public void setMimeTypes(Set<String> mimeTypes)
Set the mime types.

参数:
mimeTypes - the mime types to set

setMimeTypes

public void setMimeTypes(String mimeTypes)
Set the mime types.

参数:
mimeTypes - the mime types to set

getExcluded

public Set<String> getExcluded()
Get the excluded user agents.

返回:
excluded user agents

setExcluded

public void setExcluded(Set<String> excluded)
Set the excluded user agents.

参数:
excluded - excluded user agents to set

setExcluded

public void setExcluded(String excluded)
Set the excluded user agents.

参数:
excluded - excluded user agents to set

getVary

public String getVary()
返回:
The value of the Vary header set if a response can be compressed.

setVary

public void setVary(String vary)
Set the value of the Vary header sent with responses that could be compressed.

By default it is set to 'Accept-Encoding, User-Agent' since IE6 is excluded by default from the excludedAgents. If user-agents are not to be excluded, then this can be set to 'Accept-Encoding'. Note also that shared caches may cache many copies of a resource that is varied by User-Agent - one per variation of the User-Agent, unless the cache does some normalization of the UA string.

参数:
vary - The value of the Vary header set if a response can be compressed.

getBufferSize

public int getBufferSize()
Get the buffer size.

返回:
the buffer size

setBufferSize

public void setBufferSize(int bufferSize)
Set the buffer size.

参数:
bufferSize - buffer size to set

getMinGzipSize

public int getMinGzipSize()
Get the minimum reponse size.

返回:
minimum reponse size

setMinGzipSize

public void setMinGzipSize(int minGzipSize)
Set the minimum reponse size.

参数:
minGzipSize - minimum reponse size

handle

public void handle(String target,
                   Request baseRequest,
                   HttpServletRequest request,
                   HttpServletResponse response)
            throws IOException,
                   ServletException
从接口 Handler 复制的描述
Handle a request.

指定者:
接口 Handler 中的 handle
覆盖:
HandlerWrapper 中的 handle
参数:
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.
抛出:
IOException
ServletException
另请参见:
HandlerWrapper.handle(java.lang.String, org.eclipse.jetty.server.Request, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)

newGzipResponseWrapper

protected CompressedResponseWrapper newGzipResponseWrapper(HttpServletRequest request,
                                                           HttpServletResponse response)
Allows derived implementations to replace ResponseWrapper implementation.

参数:
request - the request
response - the response
返回:
the gzip response wrapper

newWriter

protected PrintWriter newWriter(OutputStream out,
                                String encoding)
                         throws UnsupportedEncodingException
Allows derived implementations to replace PrintWriter implementation.

参数:
out - the out
encoding - the encoding
返回:
the prints the writer
抛出:
UnsupportedEncodingException


Copyright © 2013. All Rights Reserved.