Package com.helger.xservlet.filter
Class XServletFilterConsistency
- java.lang.Object
-
- com.helger.xservlet.filter.XServletFilterConsistency
-
- All Implemented Interfaces:
IXServletLowLevelFilter
public class XServletFilterConsistency extends Object implements IXServletLowLevelFilter
Handle special content related stuff that needs to be processed for every servlet. Currently handled are:- Request fallback charset
- Response fallback charset
- Since:
- 9.0.0
- Author:
- Philip Helger
-
-
Field Summary
Fields Modifier and Type Field Description static XServletFilterConsistencyINSTANCE
-
Constructor Summary
Constructors Modifier Constructor Description protectedXServletFilterConsistency()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidafterRequest(javax.servlet.http.HttpServletRequest aHttpRequest, javax.servlet.http.HttpServletResponse aHttpResponse, com.helger.http.EHttpVersion eHttpVersion, com.helger.commons.http.EHttpMethod eHttpMethod, boolean bInvokeHandler, Throwable aCaughtException, boolean bIsHandledAsync)Invoked after an XServlet request was handled.com.helger.commons.state.EContinuebeforeRequest(javax.servlet.http.HttpServletRequest aHttpRequest, javax.servlet.http.HttpServletResponse aHttpResponse, com.helger.http.EHttpVersion eHttpVersion, com.helger.commons.http.EHttpMethod eHttpMethod)Invoked before an XServlet request is handled.protected voidcheckCharacterEncoding(String sRequestURL, String sCharacterEncoding, int nStatusCode, com.helger.commons.http.EHttpMethod eHttpMethod)protected voidcheckContentType(String sRequestURL, String sContentType, int nStatusCode, com.helger.commons.http.EHttpMethod eHttpMethod)protected voidcheckHeaders(String sRequestURL, com.helger.commons.http.HttpHeaderMap aHeaders, int nStatusCode, com.helger.commons.http.EHttpMethod eHttpMethod)protected voidcheckStatusCode(String sRequestURL, int nStatusCode, com.helger.commons.http.EHttpMethod eHttpMethod)static booleanisSilentMode()static booleansetSilentMode(boolean bSilentMode)Enable or disable certain regular log messages.
-
-
-
Field Detail
-
INSTANCE
public static final XServletFilterConsistency INSTANCE
-
-
Method Detail
-
isSilentMode
public static boolean isSilentMode()
- Returns:
trueif logging is disabled,falseif it is enabled.- Since:
- 9.1.7
-
setSilentMode
public static boolean setSilentMode(boolean bSilentMode)
Enable or disable certain regular log messages.- Parameters:
bSilentMode-trueto disable logging,falseto enable logging- Returns:
- The previous value of the silent mode.
- Since:
- 9.1.7
-
beforeRequest
@Nonnull public com.helger.commons.state.EContinue beforeRequest(@Nonnull javax.servlet.http.HttpServletRequest aHttpRequest, @Nonnull javax.servlet.http.HttpServletResponse aHttpResponse, @Nonnull com.helger.http.EHttpVersion eHttpVersion, @Nonnull com.helger.commons.http.EHttpMethod eHttpMethod)
Description copied from interface:IXServletLowLevelFilterInvoked before an XServlet request is handled. This method is created before the request is created! Exceptions occurring in this method will be propagated to the outside, so be careful :)- Specified by:
beforeRequestin interfaceIXServletLowLevelFilter- Parameters:
aHttpRequest- HTTP servlet request. Nevernull.aHttpResponse- HTTP servlet response. Nevernull.eHttpVersion- HTTP version. Nevernull.eHttpMethod- HTTP method. Nevernull.- Returns:
EContinue.CONTINUEto continue processing, orEContinue.BREAKif this request should not be processed, in which case the HttpServletResponse must contain a valid response!
-
checkStatusCode
@OverrideOnDemand protected void checkStatusCode(@Nonnull String sRequestURL, int nStatusCode, @Nonnull com.helger.commons.http.EHttpMethod eHttpMethod)
- Parameters:
sRequestURL- The request URL.nStatusCode- The response status code.eHttpMethod- Used HTTP Method
-
checkCharacterEncoding
@OverrideOnDemand protected void checkCharacterEncoding(@Nonnull String sRequestURL, @Nullable String sCharacterEncoding, int nStatusCode, @Nonnull com.helger.commons.http.EHttpMethod eHttpMethod)
- Parameters:
sRequestURL- The request URL.sCharacterEncoding- The response character encoding.nStatusCode- The response status code.eHttpMethod- Used HTTP Method
-
checkContentType
@OverrideOnDemand protected void checkContentType(@Nonnull String sRequestURL, @Nullable String sContentType, int nStatusCode, @Nonnull com.helger.commons.http.EHttpMethod eHttpMethod)
- Parameters:
sRequestURL- The request URL.sContentType- The response content type.nStatusCode- The response status code.eHttpMethod- Used HTTP Method
-
checkHeaders
@OverrideOnDemand protected void checkHeaders(@Nonnull String sRequestURL, @Nonnull com.helger.commons.http.HttpHeaderMap aHeaders, int nStatusCode, @Nonnull com.helger.commons.http.EHttpMethod eHttpMethod)
- Parameters:
sRequestURL- The request URL.aHeaders- All response HTTP headers.nStatusCode- The response status code.eHttpMethod- Used HTTP Method
-
afterRequest
public void afterRequest(@Nonnull javax.servlet.http.HttpServletRequest aHttpRequest, @Nonnull javax.servlet.http.HttpServletResponse aHttpResponse, @Nonnull com.helger.http.EHttpVersion eHttpVersion, @Nonnull com.helger.commons.http.EHttpMethod eHttpMethod, boolean bInvokeHandler, @Nullable Throwable aCaughtException, boolean bIsHandledAsync)
Description copied from interface:IXServletLowLevelFilterInvoked after an XServlet request was handled. After is always called, even if before request was canceled (in a finally)! Exceptions occurring in this method will be propagated to the outside, so be careful :)
Note: the response cannot be modified in implementations of this method - they should be considered read-only. Also HTTP headers can usually NOT be modified in this method.- Specified by:
afterRequestin interfaceIXServletLowLevelFilter- Parameters:
aHttpRequest- HTTP servlet request. Nevernull.aHttpResponse- HTTP servlet response. Nevernull.eHttpVersion- HTTP version. Nevernull.eHttpMethod- HTTP method. Nevernull.bInvokeHandler-trueif the main handler was invoked,falseifIXServletLowLevelFilter.beforeRequest(HttpServletRequest, HttpServletResponse, EHttpVersion, EHttpMethod)avoided the execution of the request.aCaughtException- An optionally caught exception. May benull. The exception was already logged, so please don't log it again!bIsHandledAsync-trueif the request is handled asynchronously
-
-