public class ContentCachingRequestWrapper extends HttpServletRequestWrapper
HttpServletRequest wrapper that caches all content read from
the input stream and reader,
and allows this content to be retrieved via a byte array.
Used e.g. by AbstractRequestLoggingFilter.
Note: As of Spring Framework 5.0, this wrapper is built on the Servlet 3.1 API.
ContentCachingResponseWrapperBASIC_AUTH, CLIENT_CERT_AUTH, DIGEST_AUTH, FORM_AUTH| Constructor and Description |
|---|
ContentCachingRequestWrapper(HttpServletRequest request)
Create a new ContentCachingRequestWrapper for the given servlet request.
|
ContentCachingRequestWrapper(HttpServletRequest request,
int contentCacheLimit)
Create a new ContentCachingRequestWrapper for the given servlet request.
|
| Modifier and Type | Method and Description |
|---|---|
java.lang.String |
getCharacterEncoding() |
byte[] |
getContentAsByteArray()
Return the cached request content as a byte array.
|
ServletInputStream |
getInputStream() |
java.lang.String |
getParameter(java.lang.String name) |
java.util.Map<java.lang.String,java.lang.String[]> |
getParameterMap() |
java.util.Enumeration<java.lang.String> |
getParameterNames() |
java.lang.String[] |
getParameterValues(java.lang.String name) |
java.io.BufferedReader |
getReader() |
protected void |
handleContentOverflow(int contentCacheLimit)
Template method for handling a content overflow: specifically, a request
body being read that exceeds the specified content cache limit.
|
authenticate, changeSessionId, getAuthType, getContextPath, getCookies, getDateHeader, getHeader, getHeaderNames, getHeaders, getIntHeader, getMethod, getPart, getParts, getPathInfo, getPathTranslated, getQueryString, getRemoteUser, getRequestedSessionId, getRequestURI, getRequestURL, getServletPath, getSession, getSession, getUserPrincipal, isRequestedSessionIdFromCookie, isRequestedSessionIdFromUrl, isRequestedSessionIdFromURL, isRequestedSessionIdValid, isUserInRole, login, logout, upgradegetAsyncContext, getAttribute, getAttributeNames, getContentLength, getContentLengthLong, getContentType, getDispatcherType, getLocalAddr, getLocale, getLocales, getLocalName, getLocalPort, getProtocol, getRealPath, getRemoteAddr, getRemoteHost, getRemotePort, getRequest, getRequestDispatcher, getScheme, getServerName, getServerPort, getServletContext, isAsyncStarted, isAsyncSupported, isSecure, isWrapperFor, isWrapperFor, removeAttribute, setAttribute, setCharacterEncoding, setRequest, startAsync, startAsyncclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitgetAsyncContext, getAttribute, getAttributeNames, getContentLength, getContentLengthLong, getContentType, getDispatcherType, getLocalAddr, getLocale, getLocales, getLocalName, getLocalPort, getProtocol, getRealPath, getRemoteAddr, getRemoteHost, getRemotePort, getRequestDispatcher, getScheme, getServerName, getServerPort, getServletContext, isAsyncStarted, isAsyncSupported, isSecure, removeAttribute, setAttribute, setCharacterEncoding, startAsync, startAsyncpublic ContentCachingRequestWrapper(HttpServletRequest request)
request - the original servlet requestpublic ContentCachingRequestWrapper(HttpServletRequest request, int contentCacheLimit)
request - the original servlet requestcontentCacheLimit - the maximum number of bytes to cache per requesthandleContentOverflow(int)public ServletInputStream getInputStream() throws java.io.IOException
getInputStream in interface ServletRequestgetInputStream in class ServletRequestWrapperjava.io.IOExceptionpublic java.lang.String getCharacterEncoding()
getCharacterEncoding in interface ServletRequestgetCharacterEncoding in class ServletRequestWrapperpublic java.io.BufferedReader getReader()
throws java.io.IOException
getReader in interface ServletRequestgetReader in class ServletRequestWrapperjava.io.IOExceptionpublic java.lang.String getParameter(java.lang.String name)
getParameter in interface ServletRequestgetParameter in class ServletRequestWrapperpublic java.util.Map<java.lang.String,java.lang.String[]> getParameterMap()
getParameterMap in interface ServletRequestgetParameterMap in class ServletRequestWrapperpublic java.util.Enumeration<java.lang.String> getParameterNames()
getParameterNames in interface ServletRequestgetParameterNames in class ServletRequestWrapperpublic java.lang.String[] getParameterValues(java.lang.String name)
getParameterValues in interface ServletRequestgetParameterValues in class ServletRequestWrapperpublic byte[] getContentAsByteArray()
The returned array will never be larger than the content cache limit.
protected void handleContentOverflow(int contentCacheLimit)
The default implementation is empty. Subclasses may override this to throw a payload-too-large exception or the like.
contentCacheLimit - the maximum number of bytes to cache per request
which has just been exceededContentCachingRequestWrapper(HttpServletRequest, int)