public class ForwardedHeaderFilter extends OncePerRequestFilter
getServerName(),
getServerPort(),
getScheme(), and
isSecure() methods with values derived
from "Forwarded" or "X-Forwarded-*" headers. In effect the wrapped request
reflects the client-originated protocol and address.ALREADY_FILTERED_SUFFIXlogger| Constructor and Description |
|---|
ForwardedHeaderFilter() |
| Modifier and Type | Method and Description |
|---|---|
protected void |
doFilterInternal(HttpServletRequest request,
HttpServletResponse response,
FilterChain filterChain)
Same contract as for
doFilter, but guaranteed to be
just invoked once per request within a single request thread. |
protected boolean |
shouldNotFilter(HttpServletRequest request)
Can be overridden in subclasses for custom filtering control,
returning
true to avoid filtering of the given request. |
protected boolean |
shouldNotFilterAsyncDispatch()
The dispatcher type
javax.servlet.DispatcherType.ASYNC introduced
in Servlet 3.0 means a filter can be invoked in more than one thread
over the course of a single request. |
protected boolean |
shouldNotFilterErrorDispatch()
Whether to filter error dispatches such as when the servlet container
processes and error mapped in
web.xml. |
doFilter, getAlreadyFilteredAttributeName, isAsyncDispatch, isAsyncStartedaddRequiredProperty, afterPropertiesSet, destroy, getFilterConfig, getFilterName, getServletContext, init, initBeanWrapper, initFilterBean, setBeanName, setEnvironment, setServletContextprotected boolean shouldNotFilter(HttpServletRequest request) throws ServletException
OncePerRequestFiltertrue to avoid filtering of the given request.
The default implementation always returns false.
shouldNotFilter in class OncePerRequestFilterrequest - current HTTP requestServletException - in case of errorsprotected boolean shouldNotFilterAsyncDispatch()
OncePerRequestFilterjavax.servlet.DispatcherType.ASYNC introduced
in Servlet 3.0 means a filter can be invoked in more than one thread
over the course of a single request. Some filters only need to filter
the initial thread (e.g. request wrapping) while others may need
to be invoked at least once in each additional thread for example for
setting up thread locals or to perform final processing at the very end.
Note that although a filter can be mapped to handle specific dispatcher
types via web.xml or in Java through the ServletContext,
servlet containers may enforce different defaults with regards to
dispatcher types. This flag enforces the design intent of the filter.
The default return value is "true", which means the filter will not be invoked during subsequent async dispatches. If "false", the filter will be invoked during async dispatches with the same guarantees of being invoked only once during a request within a single thread.
shouldNotFilterAsyncDispatch in class OncePerRequestFilterprotected boolean shouldNotFilterErrorDispatch()
OncePerRequestFilterweb.xml. The default return value
is "true", which means the filter will not be invoked in case of an error
dispatch.shouldNotFilterErrorDispatch in class OncePerRequestFilterprotected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain) throws ServletException, IOException
OncePerRequestFilterdoFilter, but guaranteed to be
just invoked once per request within a single request thread.
See OncePerRequestFilter.shouldNotFilterAsyncDispatch() for details.
Provides HttpServletRequest and HttpServletResponse arguments instead of the default ServletRequest and ServletResponse ones.
doFilterInternal in class OncePerRequestFilterServletExceptionIOException