spring-framework / org.springframework.web.util / ContentCachingResponseWrapper

ContentCachingResponseWrapper

open class ContentCachingResponseWrapper : HttpServletResponseWrapper

javax.servlet.http.HttpServletResponse wrapper that caches all content written to the output stream and writer, and allows this content to be retrieved via a byte array.

Used e.g. by org.springframework.web.filter.ShallowEtagHeaderFilter. Note: As of Spring Framework 5.0, this wrapper is built on the Servlet 3.1 API.

Author
Juergen Hoeller

Since
4.1.3

See Also
ContentCachingRequestWrapper

Constructors

<init>

ContentCachingResponseWrapper(response: HttpServletResponse)

Create a new ContentCachingResponseWrapper for the given servlet response.

Functions

copyBodyToResponse

open fun copyBodyToResponse(): Unit

Copy the complete cached body content to the response.

flushBuffer

open fun flushBuffer(): Unit

getContentAsByteArray

open fun getContentAsByteArray(): ByteArray

Return the cached response content as a byte array.

getContentInputStream

open fun getContentInputStream(): InputStream

Return an InputStream to the cached content.

getContentSize

open fun getContentSize(): Int

Return the current size of the cached content.

getOutputStream

open fun getOutputStream(): ServletOutputStream

getStatusCode

open fun getStatusCode(): Int

Return the status code as specified on the response.

getWriter

open fun getWriter(): PrintWriter

reset

open fun reset(): Unit

resetBuffer

open fun resetBuffer(): Unit

sendError

open fun sendError(sc: Int): Unit
open fun sendError(sc: Int, msg: String): Unit

sendRedirect

open fun sendRedirect(location: String): Unit

setBufferSize

open fun setBufferSize(size: Int): Unit

setContentLength

open fun setContentLength(len: Int): Unit

setContentLengthLong

open fun setContentLengthLong(len: Long): Unit

setStatus

open fun setStatus(sc: Int): Unit
open fun setStatus(sc: Int, sm: String): Unit