org.ibisph.filter.gzip
Class Filter
java.lang.Object
org.ibisph.filter.AbstractPathPatternFilter
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 NAME | INIT-PARAM DESCRIPTION |
| Path Patterns |
Typical pattern path list properties. |
- Author:
- Garth Braithwaite, STG
|
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 java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Filter
public Filter()
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