org.springframework.web.filter
Class ShallowEtagHeaderFilter
java.lang.Object
org.springframework.web.filter.GenericFilterBean
org.springframework.web.filter.OncePerRequestFilter
org.springframework.web.filter.ShallowEtagHeaderFilter
- All Implemented Interfaces:
- javax.servlet.Filter, BeanNameAware, DisposableBean, InitializingBean, ServletContextAware
public class ShallowEtagHeaderFilter
- extends OncePerRequestFilter
Servlet 2.3/2.4 Filter that generates an ETag value based on the content on the
response. This ETag is compared to the If-None-Match header of the request. If these headers are equal,
the resonse content is not sent, but rather a 304 "Not Modified" status.
Since the ETag is based on the response content, the response (or View)
is still rendered. As such, this filter only saves bandwith, not performance.
- Since:
- 3.0
- Author:
- Arjen Poutsma
|
Method Summary |
protected void |
doFilterInternal(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response,
javax.servlet.FilterChain filterChain)
Same contract as for doFilter, but guaranteed to be
just invoked once per request. |
protected java.lang.String |
generateETagHeaderValue(byte[] bytes)
Generates the ETag header value from the given response body bytes array. |
| Methods inherited from class org.springframework.web.filter.GenericFilterBean |
addRequiredProperty, afterPropertiesSet, destroy, getFilterConfig, getFilterName, getServletContext, init, initBeanWrapper, initFilterBean, setBeanName, setServletContext |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
ShallowEtagHeaderFilter
public ShallowEtagHeaderFilter()
doFilterInternal
protected void doFilterInternal(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response,
javax.servlet.FilterChain filterChain)
throws javax.servlet.ServletException,
java.io.IOException
- Description copied from class:
OncePerRequestFilter
- Same contract as for
doFilter, but guaranteed to be
just invoked once per request. Provides HttpServletRequest and
HttpServletResponse arguments instead of the default ServletRequest
and ServletResponse ones.
- Specified by:
doFilterInternal in class OncePerRequestFilter
- Throws:
javax.servlet.ServletException
java.io.IOException
generateETagHeaderValue
protected java.lang.String generateETagHeaderValue(byte[] bytes)
- Generates the ETag header value from the given response body bytes array.
Default implementation generates an MD5 hash.
- Parameters:
bytes - the
- Returns:
- the ETag header value
- See Also:
Md5HashUtils