类 ContentCachingRequestWrapper
- 所有已实现的接口:
HttpServletRequest,ServletRequest
HttpServletRequest wrapper that caches all content read from
the input stream and reader,
and allows this content to be retrieved via a byte array.
This class acts as an interceptor that only caches content as it is being
read but otherwise does not cause content to be read. That means if the request
content is not consumed, then the content is not cached, and cannot be
retrieved via getContentAsByteArray().
- 从以下版本开始:
- 4.0
- 作者:
- Juergen Hoeller, Brian Clozel, Harry Yang
- 另请参阅:
-
嵌套类概要
嵌套类 -
字段概要
字段修饰符和类型字段说明private final cn.taketoday.util.FastByteArrayOutputStreamprivate final Integerprivate ServletInputStreamprivate BufferedReader从接口继承的字段 jakarta.servlet.http.HttpServletRequest
BASIC_AUTH, CLIENT_CERT_AUTH, DIGEST_AUTH, FORM_AUTH -
构造器概要
构造器构造器说明Create a new ContentCachingRequestWrapper for the given servlet request.ContentCachingRequestWrapper(HttpServletRequest request, int contentCacheLimit) Create a new ContentCachingRequestWrapper for the given servlet request. -
方法概要
修饰符和类型方法说明byte[]Return the cached request content as a byte array.Return the cached request content as a String, using the configuredCharset.getParameter(String name) String[]getParameterValues(String name) protected voidhandleContentOverflow(int contentCacheLimit) Template method for handling a content overflow: specifically, a request body being read that exceeds the specified content cache limit.private booleanprivate void从类继承的方法 jakarta.servlet.http.HttpServletRequestWrapper
authenticate, changeSessionId, getAuthType, getContextPath, getCookies, getDateHeader, getHeader, getHeaderNames, getHeaders, getHttpServletMapping, getIntHeader, getMethod, getPart, getParts, getPathInfo, getPathTranslated, getQueryString, getRemoteUser, getRequestedSessionId, getRequestURI, getRequestURL, getServletPath, getSession, getSession, getTrailerFields, getUserPrincipal, isRequestedSessionIdFromCookie, isRequestedSessionIdFromURL, isRequestedSessionIdValid, isTrailerFieldsReady, isUserInRole, login, logout, newPushBuilder, upgrade从类继承的方法 jakarta.servlet.ServletRequestWrapper
getAsyncContext, getAttribute, getAttributeNames, getContentLength, getContentLengthLong, getContentType, getDispatcherType, getLocalAddr, getLocale, getLocales, getLocalName, getLocalPort, getProtocol, getProtocolRequestId, getRemoteAddr, getRemoteHost, getRemotePort, getRequest, getRequestDispatcher, getRequestId, getScheme, getServerName, getServerPort, getServletConnection, getServletContext, isAsyncStarted, isAsyncSupported, isSecure, isWrapperFor, isWrapperFor, removeAttribute, setAttribute, setCharacterEncoding, setRequest, startAsync, startAsync从类继承的方法 java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait从接口继承的方法 jakarta.servlet.ServletRequest
getAsyncContext, getAttribute, getAttributeNames, getContentLength, getContentLengthLong, getContentType, getDispatcherType, getLocalAddr, getLocale, getLocales, getLocalName, getLocalPort, getProtocol, getProtocolRequestId, getRemoteAddr, getRemoteHost, getRemotePort, getRequestDispatcher, getRequestId, getScheme, getServerName, getServerPort, getServletConnection, getServletContext, isAsyncStarted, isAsyncSupported, isSecure, removeAttribute, setAttribute, setCharacterEncoding, startAsync, startAsync
-
字段详细资料
-
cachedContent
private final cn.taketoday.util.FastByteArrayOutputStream cachedContent -
contentCacheLimit
-
inputStream
-
reader
-
-
构造器详细资料
-
ContentCachingRequestWrapper
Create a new ContentCachingRequestWrapper for the given servlet request.- 参数:
request- the original servlet request
-
ContentCachingRequestWrapper
Create a new ContentCachingRequestWrapper for the given servlet request.- 参数:
request- the original servlet requestcontentCacheLimit- the maximum number of bytes to cache per request- 另请参阅:
-
-
方法详细资料
-
getInputStream
- 指定者:
getInputStream在接口中ServletRequest- 覆盖:
getInputStream在类中ServletRequestWrapper- 抛出:
IOException
-
getCharacterEncoding
- 指定者:
getCharacterEncoding在接口中ServletRequest- 覆盖:
getCharacterEncoding在类中ServletRequestWrapper
-
getReader
- 指定者:
getReader在接口中ServletRequest- 覆盖:
getReader在类中ServletRequestWrapper- 抛出:
IOException
-
getParameter
- 指定者:
getParameter在接口中ServletRequest- 覆盖:
getParameter在类中ServletRequestWrapper
-
getParameterMap
- 指定者:
getParameterMap在接口中ServletRequest- 覆盖:
getParameterMap在类中ServletRequestWrapper
-
getParameterNames
- 指定者:
getParameterNames在接口中ServletRequest- 覆盖:
getParameterNames在类中ServletRequestWrapper
-
getParameterValues
- 指定者:
getParameterValues在接口中ServletRequest- 覆盖:
getParameterValues在类中ServletRequestWrapper
-
isFormPost
private boolean isFormPost() -
writeRequestParametersToCachedContent
private void writeRequestParametersToCachedContent() -
getContentAsByteArray
public byte[] getContentAsByteArray()Return the cached request content as a byte array.The returned array will never be larger than the content cache limit.
Note: The byte array returned from this method reflects the amount of content that has been read at the time when it is called. If the application does not read the content, this method returns an empty array.
-
getContentAsString
Return the cached request content as a String, using the configuredCharset.Note: The String returned from this method reflects the amount of content that has been read at the time when it is called. If the application does not read the content, this method returns an empty String.
- 另请参阅:
-
handleContentOverflow
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.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 exceeded- 另请参阅:
-