public class GzipFilter extends UserAgentFilter
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 filter is mapped for static content, then use of efficient direct NIO may be
prevented, thus use of the gzip mechanism of the org.mortbay.jetty.servlet.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.
| Modifier and Type | Class and Description |
|---|---|
class |
GzipFilter.GZIPResponseWrapper |
static class |
GzipFilter.GzipStream |
| Modifier and Type | Field and Description |
|---|---|
protected int |
_bufferSize |
protected Set |
_excluded |
protected Set |
_mimeTypes |
protected int |
_minGzipSize |
| Constructor and Description |
|---|
GzipFilter() |
| Modifier and Type | Method and Description |
|---|---|
void |
destroy() |
void |
doFilter(ServletRequest req,
ServletResponse res,
FilterChain chain) |
void |
init(FilterConfig filterConfig) |
protected GzipFilter.GZIPResponseWrapper |
newGZIPResponseWrapper(HttpServletRequest request,
HttpServletResponse response) |
protected PrintWriter |
newWriter(OutputStream out,
String encoding) |
getUserAgent, getUserAgentprotected Set _mimeTypes
protected int _bufferSize
protected int _minGzipSize
protected Set _excluded
public void init(FilterConfig filterConfig) throws ServletException
init in interface Filterinit in class UserAgentFilterServletExceptionpublic void destroy()
destroy in interface Filterdestroy in class UserAgentFilterpublic void doFilter(ServletRequest req, ServletResponse res, FilterChain chain) throws IOException, ServletException
doFilter in interface FilterdoFilter in class UserAgentFilterIOExceptionServletExceptionprotected GzipFilter.GZIPResponseWrapper newGZIPResponseWrapper(HttpServletRequest request, HttpServletResponse response)
protected PrintWriter newWriter(OutputStream out, String encoding) throws UnsupportedEncodingException
UnsupportedEncodingExceptionCopyright © 2009 Mortbay Consulting Pty. Ltd. All Rights Reserved.