|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object javax.servlet.ServletResponseWrapper javax.servlet.http.HttpServletResponseWrapper org.weborganic.bastille.cache.util.CachedResponseWrapper
public final class CachedResponseWrapper
Provides a wrapper for use with the caching filters.
This is the response that is supplied to the filters and servlets in the filter chain.
Nested Class Summary | |
---|---|
static class |
CachedResponseWrapper.FilterOutputStream
A custom ServletOutputStream for this wrapper. |
Field Summary |
---|
Fields inherited from interface javax.servlet.http.HttpServletResponse |
---|
SC_ACCEPTED, SC_BAD_GATEWAY, SC_BAD_REQUEST, SC_CONFLICT, SC_CONTINUE, SC_CREATED, SC_EXPECTATION_FAILED, SC_FORBIDDEN, SC_FOUND, SC_GATEWAY_TIMEOUT, SC_GONE, SC_HTTP_VERSION_NOT_SUPPORTED, SC_INTERNAL_SERVER_ERROR, SC_LENGTH_REQUIRED, SC_METHOD_NOT_ALLOWED, SC_MOVED_PERMANENTLY, SC_MOVED_TEMPORARILY, SC_MULTIPLE_CHOICES, SC_NO_CONTENT, SC_NON_AUTHORITATIVE_INFORMATION, SC_NOT_ACCEPTABLE, SC_NOT_FOUND, SC_NOT_IMPLEMENTED, SC_NOT_MODIFIED, SC_OK, SC_PARTIAL_CONTENT, SC_PAYMENT_REQUIRED, SC_PRECONDITION_FAILED, SC_PROXY_AUTHENTICATION_REQUIRED, SC_REQUEST_ENTITY_TOO_LARGE, SC_REQUEST_TIMEOUT, SC_REQUEST_URI_TOO_LONG, SC_REQUESTED_RANGE_NOT_SATISFIABLE, SC_RESET_CONTENT, SC_SEE_OTHER, SC_SERVICE_UNAVAILABLE, SC_SWITCHING_PROTOCOLS, SC_TEMPORARY_REDIRECT, SC_UNAUTHORIZED, SC_UNSUPPORTED_MEDIA_TYPE, SC_USE_PROXY |
Constructor Summary | |
---|---|
CachedResponseWrapper(javax.servlet.http.HttpServletResponse res)
Creates a cached response wrapper. |
Method Summary | |
---|---|
void |
addCookie(javax.servlet.http.Cookie cookie)
|
void |
addDateHeader(String name,
long date)
|
void |
addHeader(String name,
String value)
|
void |
addIntHeader(String name,
int value)
|
void |
adjustVaryAcceptEncoding(boolean add)
Adds the "Vary: Accept-Encoding" header to this response. |
void |
flush()
Flushes all the streams for this response. |
void |
flushBuffer()
Flushes buffer and commits response to client. |
List<HttpHeader<? extends Serializable>> |
getAllHeaders()
|
int |
getContentLength()
|
String |
getContentType()
|
Collection<javax.servlet.http.Cookie> |
getCookies()
|
long |
getDateHeader(String name)
|
String |
getHeader(String name)
|
List<Serializable> |
getHeaderValues(String name)
|
javax.servlet.ServletOutputStream |
getOutputStream()
|
int |
getStatus()
|
PrintWriter |
getWriter()
|
void |
reset()
Resets the response. |
void |
sendError(int code)
Send the error. |
void |
sendError(int code,
String string)
Send the error. |
void |
sendRedirect(String url)
Send the redirect. |
void |
setContentLength(int length)
|
void |
setContentType(String type)
|
void |
setDateHeader(String name,
long date)
|
void |
setHeader(String name,
String value)
|
void |
setIntHeader(String name,
int value)
|
void |
setStatus(int status)
|
void |
setStatus(int code,
String msg)
|
byte[] |
toByteArray()
|
Methods inherited from class javax.servlet.http.HttpServletResponseWrapper |
---|
containsHeader, encodeRedirectUrl, encodeRedirectURL, encodeUrl, encodeURL, getHeaderNames, getHeaders |
Methods inherited from class javax.servlet.ServletResponseWrapper |
---|
getBufferSize, getCharacterEncoding, getLocale, getResponse, isCommitted, isWrapperFor, isWrapperFor, resetBuffer, setBufferSize, setCharacterEncoding, setLocale, setResponse |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface javax.servlet.ServletResponse |
---|
getBufferSize, getCharacterEncoding, getLocale, isCommitted, resetBuffer, setBufferSize, setCharacterEncoding, setLocale |
Constructor Detail |
---|
public CachedResponseWrapper(javax.servlet.http.HttpServletResponse res)
res
- The HTTP responseMethod Detail |
---|
public javax.servlet.ServletOutputStream getOutputStream()
getOutputStream
in interface javax.servlet.ServletResponse
getOutputStream
in class javax.servlet.ServletResponseWrapper
public PrintWriter getWriter() throws IOException
getWriter
in interface javax.servlet.ServletResponse
getWriter
in class javax.servlet.ServletResponseWrapper
IOException
- If thrown while creating a new PrintWriter
instance.public void setStatus(int status)
setStatus
in interface javax.servlet.http.HttpServletResponse
setStatus
in class javax.servlet.http.HttpServletResponseWrapper
public void sendError(int code, String string) throws IOException
If the response is not OK, most of the logic is bypassed and the error is sent raw and the content is not cached.
sendError
in interface javax.servlet.http.HttpServletResponse
sendError
in class javax.servlet.http.HttpServletResponseWrapper
IOException
public void sendError(int code) throws IOException
If the response is not OK, most of the logic is bypassed and the error is sent raw and the content is not cached.
sendError
in interface javax.servlet.http.HttpServletResponse
sendError
in class javax.servlet.http.HttpServletResponseWrapper
IOException
public void sendRedirect(String url) throws IOException
If the response is not OK, most of the logic is bypassed and the error is sent raw and the content is not cached.
sendRedirect
in interface javax.servlet.http.HttpServletResponse
sendRedirect
in class javax.servlet.http.HttpServletResponseWrapper
IOException
public void setStatus(int code, String msg)
setStatus
in interface javax.servlet.http.HttpServletResponse
setStatus
in class javax.servlet.http.HttpServletResponseWrapper
public void setContentLength(int length)
setContentLength
in interface javax.servlet.ServletResponse
setContentLength
in class javax.servlet.ServletResponseWrapper
public void setContentType(String type)
setContentType
in interface javax.servlet.ServletResponse
setContentType
in class javax.servlet.ServletResponseWrapper
public String getContentType()
getContentType
in interface javax.servlet.ServletResponse
getContentType
in class javax.servlet.ServletResponseWrapper
public void addHeader(String name, String value)
addHeader
in interface javax.servlet.http.HttpServletResponse
addHeader
in class javax.servlet.http.HttpServletResponseWrapper
public void setHeader(String name, String value)
setHeader
in interface javax.servlet.http.HttpServletResponse
setHeader
in class javax.servlet.http.HttpServletResponseWrapper
public void addDateHeader(String name, long date)
addDateHeader
in interface javax.servlet.http.HttpServletResponse
addDateHeader
in class javax.servlet.http.HttpServletResponseWrapper
public void setDateHeader(String name, long date)
setDateHeader
in interface javax.servlet.http.HttpServletResponse
setDateHeader
in class javax.servlet.http.HttpServletResponseWrapper
public void addIntHeader(String name, int value)
addIntHeader
in interface javax.servlet.http.HttpServletResponse
addIntHeader
in class javax.servlet.http.HttpServletResponseWrapper
public void setIntHeader(String name, int value)
setIntHeader
in interface javax.servlet.http.HttpServletResponse
setIntHeader
in class javax.servlet.http.HttpServletResponseWrapper
public void addCookie(javax.servlet.http.Cookie cookie)
addCookie
in interface javax.servlet.http.HttpServletResponse
addCookie
in class javax.servlet.http.HttpServletResponseWrapper
public void flushBuffer() throws IOException
This method does not flush the buffer of the underlying stream so as to avoid the response to commit the response prematurely.
flushBuffer
in interface javax.servlet.ServletResponse
flushBuffer
in class javax.servlet.ServletResponseWrapper
IOException
- if thrown while flushing the underlying buffer.public void reset()
reset
in interface javax.servlet.ServletResponse
reset
in class javax.servlet.ServletResponseWrapper
public int getStatus()
getStatus
in interface javax.servlet.http.HttpServletResponse
getStatus
in class javax.servlet.http.HttpServletResponseWrapper
public int getContentLength()
public Collection<javax.servlet.http.Cookie> getCookies()
public List<HttpHeader<? extends Serializable>> getAllHeaders()
public List<Serializable> getHeaderValues(String name)
name
- the name of the header
public String getHeader(String name)
getHeader
in interface javax.servlet.http.HttpServletResponse
getHeader
in class javax.servlet.http.HttpServletResponseWrapper
name
- the name of the header
public long getDateHeader(String name)
name
- the name of the header
public void flush() throws IOException
IOException
- if thrown by the underlying output stream or writerpublic byte[] toByteArray()
public void adjustVaryAcceptEncoding(boolean add)
add
- true
to add the "Accept-Encoding" to the Vary header;
false
to remove it.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |