org.ibisph.filter.gzip
Class Filter

java.lang.Object
  extended by org.ibisph.filter.AbstractPathPatternFilter
      extended by org.ibisph.filter.gzip.Filter
All Implemented Interfaces:
javax.servlet.Filter

public class Filter
extends AbstractPathPatternFilter

GZIP compression filter for clients that can accept zipped content responses. Most application servers provide auto compression of HTML content. However, not all do and since we're doing SVG text content and our own artifact caching, it was implemented as a filter.

Filter Init Params:

PARAMETER NAMEINIT-PARAM DESCRIPTION
Path Patterns Typical pattern path list properties.

Author:
Garth Braithwaite, STG

Nested Class Summary
 
Nested classes/interfaces inherited from class org.ibisph.filter.AbstractPathPatternFilter
AbstractPathPatternFilter.PathPattern
 
Field Summary
 
Fields inherited from class org.ibisph.filter.AbstractPathPatternFilter
LIST_SEPERATOR_PARAM_NAME, MATCH_LIST_PARAM_NAME, MATCH_TYPE_PARAM_NAME, pathPattern, REQUEST_PATH_TYPE_PARAM_NAME
 
Constructor Summary
Filter()
           
 
Method Summary
 void doFilter(javax.servlet.ServletRequest req, javax.servlet.ServletResponse res, javax.servlet.FilterChain chain)
          Wraps the response with a zippable stream if client's browser supports gzip content.
 
Methods inherited from class org.ibisph.filter.AbstractPathPatternFilter
destroy, getInitParameterValue, init
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Filter

public Filter()
Method Detail

doFilter

public void doFilter(javax.servlet.ServletRequest req,
                     javax.servlet.ServletResponse res,
                     javax.servlet.FilterChain chain)
              throws java.io.IOException,
                     javax.servlet.ServletException
Wraps the response with a zippable stream if client's browser supports gzip content. Tests if the user's browser accepts "gzip" compression (via the header accept-encoding == "gzip". If it does, the response is wrapped and a capturing stream is used to capture the downstream response stream. This stream is then fed as the input stream to the compression object. The original response's stream is then used as the destination response stream for the compressed data.

Parameters:
req - Original request which is used to get if the user's browser supports compression.
res - Original response that will receive the compressed output stream (if user's browser supports).
chain - Filter chain to call for downstream request/response handling.
Throws:
java.io.IOException
javax.servlet.ServletException