com.caucho.filters
Class GzipFilter

java.lang.Object
  extended by com.caucho.filters.GzipFilter
All Implemented Interfaces:
Filter

public class GzipFilter
extends java.lang.Object
implements Filter

Compresses the response output if the browser accepts compression.

Browsers which support gzip compression will set the Accept-Encoding header. If GzipFilter detects the gzip compression, it will compress the output.

GzipFilter will always set the "Vary: Accept-Encoding" header because the output depends on the request

Since:
Resin 2.0.6

Constructor Summary
GzipFilter()
           
 
Method Summary
 void addAllowContentType(java.lang.String type)
          Adds an allowed content type.
 void addDenyContentType(java.lang.String type)
          Adds a deny content type.
protected  void addVaryHeader(HttpServletResponse response)
           
protected  int allowGzip(HttpServletRequest req, HttpServletResponse res)
          Returns true if the GZip is allowed.
 void destroy()
          Any cleanup for the filter.
 void doFilter(ServletRequest request, ServletResponse response, FilterChain nextFilter)
          Creates a wrapper to compress the output.
 void init(FilterConfig config)
          Initialize the filter.
 void setEmbedErrorInOutput(boolean embedError)
          Set true if errors should be embedded in the output.
 void setNoCache(boolean noCache)
          Set true if the output should not be cached.
 void setUseVary(boolean useVary)
          Set true if the vary support should be enabled.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GzipFilter

public GzipFilter()
Method Detail

setUseVary

public void setUseVary(boolean useVary)
Set true if the vary support should be enabled.


setNoCache

public void setNoCache(boolean noCache)
Set true if the output should not be cached.


setEmbedErrorInOutput

public void setEmbedErrorInOutput(boolean embedError)
Set true if errors should be embedded in the output.


addAllowContentType

public void addAllowContentType(java.lang.String type)
Adds an allowed content type.


addDenyContentType

public void addDenyContentType(java.lang.String type)
Adds a deny content type.


init

public void init(FilterConfig config)
          throws ServletException
Description copied from interface: Filter
Initialize the filter.

Specified by:
init in interface Filter
Throws:
ServletException

doFilter

public void doFilter(ServletRequest request,
                     ServletResponse response,
                     FilterChain nextFilter)
              throws ServletException,
                     java.io.IOException
Creates a wrapper to compress the output.

Specified by:
doFilter in interface Filter
Parameters:
request - the servlet request
response - the servlet response
nextFilter - the next filter in the chain
Throws:
ServletException
java.io.IOException

addVaryHeader

protected void addVaryHeader(HttpServletResponse response)

allowGzip

protected int allowGzip(HttpServletRequest req,
                        HttpServletResponse res)
Returns true if the GZip is allowed.


destroy

public void destroy()
Any cleanup for the filter.

Specified by:
destroy in interface Filter