public class RelativeRedirectFilter extends OncePerRequestFilter
HttpServletResponse.sendRedirect(String)
and handles it by
setting the HTTP status and "Location" headers. This keeps the Servlet
container from re-writing relative redirect URLs and instead follows the
recommendation in
RFC 7231 Section 7.1.2.
Note: While relative redirects are more efficient they may not work with reverse proxies under some configurations.
ALREADY_FILTERED_SUFFIX
logger
Constructor and Description |
---|
RelativeRedirectFilter() |
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. |
HttpStatus |
getRedirectStatus()
Return the configured redirect status.
|
void |
setRedirectStatus(HttpStatus status)
Set the default HTTP Status to use for redirects.
|
doFilter, getAlreadyFilteredAttributeName, isAsyncDispatch, isAsyncStarted, shouldNotFilter, shouldNotFilterAsyncDispatch, shouldNotFilterErrorDispatch
addRequiredProperty, afterPropertiesSet, createEnvironment, destroy, getEnvironment, getFilterConfig, getFilterName, getServletContext, init, initBeanWrapper, initFilterBean, setBeanName, setEnvironment, setServletContext
public void setRedirectStatus(HttpStatus status)
By default this is HttpStatus.SEE_OTHER
.
status
- the 3xx redirect status to usepublic HttpStatus getRedirectStatus()
protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain) throws ServletException, IOException
OncePerRequestFilter
doFilter
, 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 OncePerRequestFilter
ServletException
IOException