org.eclipse.jetty.servlets
Class GzipFilter

java.lang.Object
  extended by org.eclipse.jetty.servlets.UserAgentFilter
      extended by org.eclipse.jetty.servlets.GzipFilter
All Implemented Interfaces:
Filter
Direct Known Subclasses:
IncludableGzipFilter

public class GzipFilter
extends UserAgentFilter

GZIP Filter This filter will gzip the content of a response iff:

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.


Field Summary
protected  int _bufferSize
           
protected  Set<String> _excluded
           
protected  Set<String> _mimeTypes
           
protected  int _minGzipSize
           
 
Constructor Summary
GzipFilter()
           
 
Method Summary
 void destroy()
           
 void doFilter(ServletRequest req, ServletResponse res, FilterChain chain)
           
 void init(FilterConfig filterConfig)
           
protected  GzipResponseWrapper 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.
 
Methods inherited from class org.eclipse.jetty.servlets.UserAgentFilter
getUserAgent, getUserAgent
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_mimeTypes

protected Set<String> _mimeTypes

_bufferSize

protected int _bufferSize

_minGzipSize

protected int _minGzipSize

_excluded

protected Set<String> _excluded
Constructor Detail

GzipFilter

public GzipFilter()
Method Detail

init

public void init(FilterConfig filterConfig)
          throws ServletException
Specified by:
init in interface Filter
Overrides:
init in class UserAgentFilter
Throws:
ServletException
See Also:
UserAgentFilter.init(javax.servlet.FilterConfig)

destroy

public void destroy()
Specified by:
destroy in interface Filter
Overrides:
destroy in class UserAgentFilter
See Also:
UserAgentFilter.destroy()

doFilter

public void doFilter(ServletRequest req,
                     ServletResponse res,
                     FilterChain chain)
              throws IOException,
                     ServletException
Specified by:
doFilter in interface Filter
Overrides:
doFilter in class UserAgentFilter
Throws:
IOException
ServletException
See Also:
UserAgentFilter.doFilter(javax.servlet.ServletRequest, javax.servlet.ServletResponse, javax.servlet.FilterChain)

newGzipResponseWrapper

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

Parameters:
request - the request
response - the response
Returns:
the gzip response wrapper

newWriter

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

Parameters:
out - the out
encoding - the encoding
Returns:
the prints the writer
Throws:
UnsupportedEncodingException


Copyright © 1995-2011 Mort Bay Consulting. All Rights Reserved.