com.sun.jersey.api.container.filter
Class GZIPContentEncodingFilter

java.lang.Object
  extended by com.sun.jersey.api.container.filter.GZIPContentEncodingFilter
All Implemented Interfaces:
ContainerRequestFilter, ContainerResponseFilter

public class GZIPContentEncodingFilter
extends java.lang.Object
implements ContainerRequestFilter, ContainerResponseFilter

A GZIP content encoding filter.

If the request contains a Content-Encoding header of "gzip" then the request entity (if any) is uncompressed using gzip. If the request contains an Accept-Encoding header containing "gzip" and an "If-None-Match" Header, entitytag value is checked: if it contains the -gzip suffix, remove this suffix, otherwise, completely remove the "if-none-match" header.

If the request contains a Accept-Encoding header that contains "gzip" then the response entity (if any) is compressed using gzip and a Content-Encoding header of "gzip" is added to the response. As this filter is active, the resource representation can be compressed. the value "Accept-Encoding" is so added to the Vary header. If any entityTag is used and content may be gzipped, the "-gzip" suffix is added to entitytag value.

When an application is deployed as a Servlet or Filter this Jersey filter can be registered using the following initialization parameters:

     <init-param>
         <param-name>com.sun.jersey.spi.container.ContainerRequestFilters</param-name>
         <param-value>com.sun.jersey.api.container.filter.GZIPContentEncodingFilter</param-value>
     </init-param>
     <init-param>
         <param-name>com.sun.jersey.spi.container.ContainerResponseFilters</param-name>
         <param-value>com.sun.jersey.api.container.filter.GZIPContentEncodingFilter</param-value>
     </init-param>
 
Note that if you're using Entitag for cache control and want to use this filter, you shoud add this filter to both ContainerFilters (Request and Response).

Author:
Paul Sandoz, Edouard Chevalier
See Also:
com.sun.jersey.api.container.filter

Constructor Summary
GZIPContentEncodingFilter()
           
 
Method Summary
 ContainerRequest filter(ContainerRequest request)
          Filter the request.
 ContainerResponse filter(ContainerRequest request, ContainerResponse response)
          Filter the response.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GZIPContentEncodingFilter

public GZIPContentEncodingFilter()
Method Detail

filter

public ContainerRequest filter(ContainerRequest request)
Description copied from interface: ContainerRequestFilter
Filter the request.

An implementation may modify the state of the request or create a new instance.

Specified by:
filter in interface ContainerRequestFilter
Parameters:
request - the request.
Returns:
the request.

filter

public ContainerResponse filter(ContainerRequest request,
                                ContainerResponse response)
Description copied from interface: ContainerResponseFilter
Filter the response.

An implementation may modify the state of the response or return a new instance.

Specified by:
filter in interface ContainerResponseFilter
Parameters:
request - the request.
response - the response.
Returns:
the response.


Copyright © 2014 Oracle Corporation. All Rights Reserved.