public class ContentCachingResponseWrapper
extends 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 ShallowEtagHeaderFilter
.
Modifier and Type | Class and Description |
---|---|
private class |
ContentCachingResponseWrapper.ResponsePrintWriter |
private class |
ContentCachingResponseWrapper.ResponseServletOutputStream |
Modifier and Type | Field and Description |
---|---|
private ResizableByteArrayOutputStream |
content |
private ServletOutputStream |
outputStream |
private int |
statusCode |
private java.io.PrintWriter |
writer |
Constructor and Description |
---|
ContentCachingResponseWrapper(HttpServletResponse response)
Create a new ContentCachingResponseWrapper for the given servlet response.
|
Modifier and Type | Method and Description |
---|---|
private void |
copyBodyToResponse() |
byte[] |
getContentAsByteArray()
Return the cached response content as a byte array.
|
ServletOutputStream |
getOutputStream() |
int |
getStatusCode()
Return the status code as specifed on the response.
|
java.io.PrintWriter |
getWriter() |
void |
reset() |
void |
resetBuffer() |
void |
sendError(int sc) |
void |
sendError(int sc,
java.lang.String msg) |
void |
sendRedirect(java.lang.String location) |
void |
setBufferSize(int size) |
void |
setContentLength(int len) |
void |
setContentLengthLong(long len) |
void |
setStatus(int sc) |
void |
setStatus(int sc,
java.lang.String sm) |
private final ResizableByteArrayOutputStream content
private final ServletOutputStream outputStream
private java.io.PrintWriter writer
private int statusCode
public ContentCachingResponseWrapper(HttpServletResponse response)
response
- the original servlet responsepublic void setStatus(int sc)
public void setStatus(int sc, java.lang.String sm)
public void sendError(int sc) throws java.io.IOException
java.io.IOException
public void sendError(int sc, java.lang.String msg) throws java.io.IOException
java.io.IOException
public void sendRedirect(java.lang.String location) throws java.io.IOException
java.io.IOException
public ServletOutputStream getOutputStream()
public java.io.PrintWriter getWriter() throws java.io.IOException
java.io.IOException
public void setContentLength(int len)
public void setContentLengthLong(long len)
public void setBufferSize(int size)
public void resetBuffer()
public void reset()
public int getStatusCode()
public byte[] getContentAsByteArray()
private void copyBodyToResponse() throws java.io.IOException
java.io.IOException