|
||||||||||
| 上一个类 下一个类 | 框架 无框架 | |||||||||
| 摘要: 嵌套 | 字段 | 构造方法 | 方法 | 详细信息: 字段 | 构造方法 | 方法 | |||||||||
java.lang.Objectorg.eclipse.jetty.servlets.UserAgentFilter
org.eclipse.jetty.servlets.GzipFilter
public class GzipFilter
GZIP Filter This filter will gzip or deflate 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"If both gzip and deflate are specified in the accept-encoding header, then gzip will be used.
Compressing the content can greatly improve the network bandwidth usage, but at a cost of memory and
CPU cycles. If this filter is mapped for static content, then use of efficient direct NIO may be
prevented, thus use of the gzip mechanism of the DefaultServlet is
advised instead.
This filter extends UserAgentFilter and if the the initParameter excludedAgents
is set to a comma separated list of user agents, then these agents will be excluded from gzip content.
Init Parameters:
bufferSize The output buffer size. Defaults to 8192. Be careful as values <= 0 will lead to an
IllegalArgumentException.
See: GZIPOutputStream.GZIPOutputStream(java.io.OutputStream, int)
and: DeflaterOutputStream.DeflaterOutputStream(java.io.OutputStream, Deflater, int)
minGzipSize Content will only be compressed if content length is either unknown or greater
than minGzipSize.
deflateCompressionLevel The compression level used for deflate compression. (0-9).
See: Deflater.Deflater(int, boolean)
deflateNoWrap The noWrap setting for deflate compression. Defaults to true. (true/false)
See: Deflater.Deflater(int, boolean)
methods Comma separated list of HTTP methods to compress. If not set, only GET requests are compressed.
mimeTypes Comma separated list of mime types to compress. See description above.
excludedAgents Comma separated list of user agents to exclude from compression. Does a
String.contains(CharSequence) to check if the excluded agent occurs
in the user-agent header. If it does -> no compression
excludeAgentPatterns Same as excludedAgents, but accepts regex patterns for more complex matching.
excludePaths Comma separated list of paths to exclude from compression.
Does a String.startsWith(String) comparison to check if the path matches.
If it does match -> no compression. To match subpaths use excludePathPatterns
instead.
excludePathPatterns Same as excludePath, but accepts regex patterns for more complex matching.
vary Set to the value of the Vary header sent with responses that could be compressed. By default it is
set to 'Vary: 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 'Vary: Accept-Encoding'. Note also
that shared caches may cache 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.
| 字段摘要 | |
|---|---|
protected int |
_bufferSize
|
protected ServletContext |
_context
|
protected int |
_deflateCompressionLevel
|
protected boolean |
_deflateNoWrap
|
protected Set<Pattern> |
_excludedAgentPatterns
|
protected Set<String> |
_excludedAgents
|
protected Set<Pattern> |
_excludedPathPatterns
|
protected Set<String> |
_excludedPaths
|
protected Set<String> |
_methods
|
protected Set<String> |
_mimeTypes
|
protected int |
_minGzipSize
|
protected String |
_vary
|
static String |
DEFLATE
|
static String |
ETAG
|
static String |
ETAG_DEFLATE
|
static String |
ETAG_GZIP
|
static String |
GZIP
|
| 构造方法摘要 | |
|---|---|
GzipFilter()
|
|
| 方法摘要 | |
|---|---|
protected void |
configureWrappedResponse(CompressedResponseWrapper wrappedResponse)
|
protected CompressedResponseWrapper |
createWrappedResponse(HttpServletRequest request,
HttpServletResponse response,
String compressionType)
|
void |
destroy()
Called by the web container to indicate to a filter that it is being taken out of service. |
void |
doFilter(ServletRequest req,
ServletResponse res,
FilterChain chain)
The doFilter method of the Filter is called by the
container each time a request/response pair is passed through the
chain due to a client request for a resource at the end of the chain. |
void |
init(FilterConfig filterConfig)
Called by the web container to indicate to a filter that it is being placed into service. |
| 从类 org.eclipse.jetty.servlets.UserAgentFilter 继承的方法 |
|---|
getUserAgent, getUserAgent |
| 从类 java.lang.Object 继承的方法 |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| 字段详细信息 |
|---|
public static final String GZIP
public static final String ETAG_GZIP
public static final String DEFLATE
public static final String ETAG_DEFLATE
public static final String ETAG
protected ServletContext _context
protected Set<String> _mimeTypes
protected int _bufferSize
protected int _minGzipSize
protected int _deflateCompressionLevel
protected boolean _deflateNoWrap
protected final Set<String> _methods
protected Set<String> _excludedAgents
protected Set<Pattern> _excludedAgentPatterns
protected Set<String> _excludedPaths
protected Set<Pattern> _excludedPathPatterns
protected String _vary
| 构造方法详细信息 |
|---|
public GzipFilter()
| 方法详细信息 |
|---|
public void init(FilterConfig filterConfig)
throws ServletException
Filter 复制的描述The servlet container calls the init method exactly once after instantiating the filter. The init method must complete successfully before the filter is asked to do any filtering work.
The web container cannot place the filter into service if the init method either
Filter 中的 initUserAgentFilter 中的 initServletExceptionUserAgentFilter.init(javax.servlet.FilterConfig)public void destroy()
Filter 复制的描述This method is only called once all threads within the filter's doFilter method have exited or after a timeout period has passed. After the web container calls this method, it will not call the doFilter method again on this instance of the filter.
This method gives the filter an opportunity to clean up any resources that are being held (for example, memory, file handles, threads) and make sure that any persistent state is synchronized with the filter's current state in memory.
Filter 中的 destroyUserAgentFilter 中的 destroyUserAgentFilter.destroy()
public void doFilter(ServletRequest req,
ServletResponse res,
FilterChain chain)
throws IOException,
ServletException
Filter 复制的描述doFilter method of the Filter is called by the
container each time a request/response pair is passed through the
chain due to a client request for a resource at the end of the chain.
The FilterChain passed in to this method allows the Filter to pass
on the request and response to the next entity in the chain.
A typical implementation of this method would follow the following pattern:
chain.doFilter()),
Filter 中的 doFilterUserAgentFilter 中的 doFilterIOException
ServletExceptionUserAgentFilter.doFilter(javax.servlet.ServletRequest, javax.servlet.ServletResponse, javax.servlet.FilterChain)
protected CompressedResponseWrapper createWrappedResponse(HttpServletRequest request,
HttpServletResponse response,
String compressionType)
protected void configureWrappedResponse(CompressedResponseWrapper wrappedResponse)
|
||||||||||
| 上一个类 下一个类 | 框架 无框架 | |||||||||
| 摘要: 嵌套 | 字段 | 构造方法 | 方法 | 详细信息: 字段 | 构造方法 | 方法 | |||||||||