com.caucho.server.http
Class CauchoResponseWrapper

java.lang.Object
  extended by com.caucho.server.http.AbstractCauchoResponse
      extended by com.caucho.server.http.CauchoResponseWrapper
All Implemented Interfaces:
CauchoResponse, HttpServletResponse, ServletResponse
Direct Known Subclasses:
IncludeResponse, JspResponse, JspResponseWrapper, ProxyCacheResponse

public class CauchoResponseWrapper
extends AbstractCauchoResponse
implements CauchoResponse


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
CauchoResponseWrapper()
           
CauchoResponseWrapper(CauchoRequest request)
           
CauchoResponseWrapper(CauchoRequest request, HttpServletResponse response)
           
 
Method Summary
 void addCookie(Cookie cookie)
          Sends a new cookie to the client.
 void addDateHeader(java.lang.String name, long date)
          Adds a header by converting a date to a string.
 void addFooter(java.lang.String key, java.lang.String value)
           
 void addHeader(java.lang.String name, java.lang.String value)
          Adds a header.
 void addIntHeader(java.lang.String name, int value)
          Adds a header by converting an integer value to a string.
 void close()
           
 void completeCache()
           
 boolean containsHeader(java.lang.String name)
          Returns true if the output headers include name
 java.lang.String encodeRedirectUrl(java.lang.String url)
           
 java.lang.String encodeRedirectURL(java.lang.String name)
          Encodes session information in a URL suitable for sendRedirect()
 java.lang.String encodeUrl(java.lang.String url)
           
 java.lang.String encodeURL(java.lang.String url)
          Encodes session information in a URL.
 void flushBuffer()
          Flushes the buffer to the client.
 AbstractHttpResponse getAbstractHttpResponse()
           
 int getBufferSize()
          Returns the size of the output buffer.
 CauchoResponse getCauchoResponse()
           
 java.lang.String getCharacterEncoding()
          Returns the character encoding the response is using for output.
 java.lang.String getContentType()
          Returns the content type for the response.
 boolean getForbidForward()
           
 java.lang.String getHeader(java.lang.String name)
          Retuns value of header with a given name
 java.util.Collection<java.lang.String> getHeaderNames()
          Returns an Iterable for header names set via HttpServletResponse.setHeader(java.lang.String, java.lang.String), HttpServletResponse.addHeader(java.lang.String, java.lang.String), HttpServletResponse.setDateHeader(java.lang.String, long), HttpServletResponse.addDateHeader(java.lang.String, long), HttpServletResponse.setIntHeader(java.lang.String, int), or HttpServletResponse.addIntHeader(java.lang.String, int), respectively.
 java.util.Collection<java.lang.String> getHeaders(java.lang.String name)
          Returns an Iterable for header values with a given name
 java.util.Locale getLocale()
          Returns the output locale.
 ServletOutputStream getOutputStream()
          Returns an output stream for writing to the client.
protected  CauchoRequest getRequest()
           
 ServletResponse getResponse()
          Return wrapped response
 AbstractResponseStream getResponseStream()
           
 int getStatus()
          Returns the current status code of this response
 java.lang.String getStatusMessage()
           
 java.io.PrintWriter getWriter()
          Returns a PrintWriter with the proper character encoding for writing text data to the client.
 boolean hasError()
           
 boolean isCauchoResponseStream()
           
 boolean isCommitted()
          Returns true if some data has actually been send to the client.
 boolean isForwardEnclosed()
           
 boolean isNoCacheUnlessVary()
           
 void killCache()
           
 void reset()
          Resets the output stream, clearing headers and the output buffer.
 void resetBuffer()
          Resets the output stream, clearing headers and the output buffer.
 void sendError(int sc)
          Sends an HTTP error page based on the status code
 void sendError(int sc, java.lang.String msg)
          Sends an HTTP error page based on the status code
protected  boolean sendInternalError(int sc, java.lang.String msg)
           
 void sendRedirect(java.lang.String location)
          Redirects the client to another page.
 void setBufferSize(int size)
          Sets the output buffer size to size.
 void setCacheInvocation(AbstractCacheFilterChain cacheFilterChain)
           
 void setCharacterEncoding(java.lang.String charset)
          Sets the character encoding the response is using for output.
 void setContentLength(int len)
          Explicitly sets the length of the result value.
 void setContentType(java.lang.String type)
          Sets the response content type.
 void setDateHeader(java.lang.String name, long date)
          Sets a header by converting a date to a string.
 void setFooter(java.lang.String key, java.lang.String value)
           
 void setForbidForward(boolean forbid)
           
 void setForwardEnclosed(boolean isForwardEnclosed)
           
 void setHasError(boolean error)
           
 void setHeader(java.lang.String name, java.lang.String value)
          Sets a header.
 void setIntHeader(java.lang.String name, int value)
          Sets a header by converting an integer value to a string.
 void setLocale(java.util.Locale locale)
          Sets the output locale.
 void setMatchCacheEntry(AbstractCacheEntry cacheEntry)
           
 void setNoCache(boolean killCache)
           
 void setPrivateCache(boolean isPrivate)
           
 void setResponse(HttpServletResponse response)
           
 void setResponseStream(AbstractResponseStream os)
           
 void setSessionId(java.lang.String id)
           
 void setStatus(int sc)
          Sets the HTTP status
 void setStatus(int sc, java.lang.String msg)
           
 java.lang.String toString()
           
 
Methods inherited from class com.caucho.server.http.AbstractCauchoResponse
writeHeaders
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface com.caucho.server.http.CauchoResponse
writeHeaders
 

Constructor Detail

CauchoResponseWrapper

public CauchoResponseWrapper()

CauchoResponseWrapper

public CauchoResponseWrapper(CauchoRequest request)

CauchoResponseWrapper

public CauchoResponseWrapper(CauchoRequest request,
                             HttpServletResponse response)
Method Detail

setResponse

public void setResponse(HttpServletResponse response)

getRequest

protected CauchoRequest getRequest()

setContentType

public void setContentType(java.lang.String type)
Description copied from interface: ServletResponse
Sets the response content type. The content type includes the character encoding. The content type must be set before calling getWriter() so the writer can use the proper character encoding.

To set the output character encoding to ISO-8859-2, use the following:

 response.setContentType("text/html; charset=ISO-8859-2");
 

Specified by:
setContentType in interface ServletResponse
Parameters:
type - the mime type of the output

getContentType

public java.lang.String getContentType()
Description copied from interface: ServletResponse
Returns the content type for the response.

Specified by:
getContentType in interface ServletResponse

getCharacterEncoding

public java.lang.String getCharacterEncoding()
Description copied from interface: ServletResponse
Returns the character encoding the response is using for output. If no character encoding is specified, ISO-8859-1 will be used.

Specified by:
getCharacterEncoding in interface ServletResponse

setCharacterEncoding

public void setCharacterEncoding(java.lang.String charset)
Description copied from interface: ServletResponse
Sets the character encoding the response is using for output. If no character encoding is specified, ISO-8859-1 will be used.

Specified by:
setCharacterEncoding in interface ServletResponse

setLocale

public void setLocale(java.util.Locale locale)
Description copied from interface: ServletResponse
Sets the output locale. The response will set the character encoding based on the locale. For example, setting the "kr" locale will set the character encoding to "EUC_KR".

Specified by:
setLocale in interface ServletResponse

getLocale

public java.util.Locale getLocale()
Description copied from interface: ServletResponse
Returns the output locale.

Specified by:
getLocale in interface ServletResponse

getOutputStream

public ServletOutputStream getOutputStream()
                                    throws java.io.IOException
Description copied from interface: ServletResponse
Returns an output stream for writing to the client. You can use the output stream to write binary data.

Specified by:
getOutputStream in interface ServletResponse
Throws:
java.io.IOException

getWriter

public java.io.PrintWriter getWriter()
                              throws java.io.IOException
Description copied from interface: ServletResponse
Returns a PrintWriter with the proper character encoding for writing text data to the client.

Specified by:
getWriter in interface ServletResponse
Throws:
java.io.IOException

setBufferSize

public void setBufferSize(int size)
Description copied from interface: ServletResponse
Sets the output buffer size to size. The servlet engine may round the size up.

Specified by:
setBufferSize in interface ServletResponse
Parameters:
size - the new output buffer size.

getBufferSize

public int getBufferSize()
Description copied from interface: ServletResponse
Returns the size of the output buffer.

Specified by:
getBufferSize in interface ServletResponse

flushBuffer

public void flushBuffer()
                 throws java.io.IOException
Description copied from interface: ServletResponse
Flushes the buffer to the client.

Specified by:
flushBuffer in interface ServletResponse
Throws:
java.io.IOException

isCommitted

public boolean isCommitted()
Description copied from interface: ServletResponse
Returns true if some data has actually been send to the client. The data will be sent if the buffer overflows or if it's explicitly flushed.

Specified by:
isCommitted in interface ServletResponse

reset

public void reset()
Description copied from interface: ServletResponse
Resets the output stream, clearing headers and the output buffer. Calling reset() after data has been committed is illegal.

Specified by:
reset in interface ServletResponse

resetBuffer

public void resetBuffer()
Description copied from interface: ServletResponse
Resets the output stream, clearing headers and the output buffer. Calling reset() after data has been committed is illegal.

Specified by:
resetBuffer in interface ServletResponse

setContentLength

public void setContentLength(int len)
Description copied from interface: ServletResponse
Explicitly sets the length of the result value. Normally, the servlet engine will handle this.

Specified by:
setContentLength in interface ServletResponse

setStatus

public void setStatus(int sc)
Description copied from interface: HttpServletResponse
Sets the HTTP status

Specified by:
setStatus in interface HttpServletResponse
Parameters:
sc - the HTTP status code

sendError

public void sendError(int sc,
                      java.lang.String msg)
               throws java.io.IOException
Description copied from interface: HttpServletResponse
Sends an HTTP error page based on the status code

Specified by:
sendError in interface HttpServletResponse
Parameters:
sc - the HTTP status code
Throws:
java.io.IOException

sendError

public void sendError(int sc)
               throws java.io.IOException
Description copied from interface: HttpServletResponse
Sends an HTTP error page based on the status code

Specified by:
sendError in interface HttpServletResponse
Parameters:
sc - the HTTP status code
Throws:
java.io.IOException

sendInternalError

protected boolean sendInternalError(int sc,
                                    java.lang.String msg)

sendRedirect

public void sendRedirect(java.lang.String location)
                  throws java.io.IOException
Description copied from interface: HttpServletResponse
Redirects the client to another page.

Specified by:
sendRedirect in interface HttpServletResponse
Parameters:
location - the location to redirect to.
Throws:
java.io.IOException

setHeader

public void setHeader(java.lang.String name,
                      java.lang.String value)
Description copied from interface: HttpServletResponse
Sets a header. This will override a previous header with the same name.

Specified by:
setHeader in interface HttpServletResponse
Parameters:
name - the header name
value - the header value

addHeader

public void addHeader(java.lang.String name,
                      java.lang.String value)
Description copied from interface: HttpServletResponse
Adds a header. If another header with the same name exists, both will be sent to the client.

Specified by:
addHeader in interface HttpServletResponse
Parameters:
name - the header name
value - the header value

containsHeader

public boolean containsHeader(java.lang.String name)
Description copied from interface: HttpServletResponse
Returns true if the output headers include name

Specified by:
containsHeader in interface HttpServletResponse
Parameters:
name - the header name to test

setDateHeader

public void setDateHeader(java.lang.String name,
                          long date)
Description copied from interface: HttpServletResponse
Sets a header by converting a date to a string.

To set the page to expire in 15 seconds use the following:


 long now = System.currentTime();
 response.setDateHeader("Expires", now + 15000);
 

Specified by:
setDateHeader in interface HttpServletResponse
Parameters:
name - name of the header
date - the date in milliseconds since the epoch.

addDateHeader

public void addDateHeader(java.lang.String name,
                          long date)
Description copied from interface: HttpServletResponse
Adds a header by converting a date to a string.

Specified by:
addDateHeader in interface HttpServletResponse
Parameters:
name - name of the header
date - the date in milliseconds since the epoch.

setIntHeader

public void setIntHeader(java.lang.String name,
                         int value)
Description copied from interface: HttpServletResponse
Sets a header by converting an integer value to a string.

Specified by:
setIntHeader in interface HttpServletResponse
Parameters:
name - name of the header
value - the value as an integer

addIntHeader

public void addIntHeader(java.lang.String name,
                         int value)
Description copied from interface: HttpServletResponse
Adds a header by converting an integer value to a string.

Specified by:
addIntHeader in interface HttpServletResponse
Parameters:
name - name of the header
value - the value as an integer

addCookie

public void addCookie(Cookie cookie)
Description copied from interface: HttpServletResponse
Sends a new cookie to the client.

Specified by:
addCookie in interface HttpServletResponse

encodeURL

public java.lang.String encodeURL(java.lang.String url)
Description copied from interface: HttpServletResponse
Encodes session information in a URL. Calling this will enable sessions for users who have disabled cookies.

Specified by:
encodeURL in interface HttpServletResponse
Parameters:
url - the url to encode
Returns:
a url with session information encoded

encodeRedirectURL

public java.lang.String encodeRedirectURL(java.lang.String name)
Description copied from interface: HttpServletResponse
Encodes session information in a URL suitable for sendRedirect()

Specified by:
encodeRedirectURL in interface HttpServletResponse
Parameters:
name - the url to encode
Returns:
a url with session information encoded

setStatus

public void setStatus(int sc,
                      java.lang.String msg)
Specified by:
setStatus in interface HttpServletResponse

encodeUrl

public java.lang.String encodeUrl(java.lang.String url)
Specified by:
encodeUrl in interface HttpServletResponse

encodeRedirectUrl

public java.lang.String encodeRedirectUrl(java.lang.String url)
Specified by:
encodeRedirectUrl in interface HttpServletResponse

getStatus

public int getStatus()
Description copied from interface: HttpServletResponse
Returns the current status code of this response

Specified by:
getStatus in interface HttpServletResponse
Returns:

getHeader

public java.lang.String getHeader(java.lang.String name)
Description copied from interface: HttpServletResponse
Retuns value of header with a given name

Specified by:
getHeader in interface CauchoResponse
Specified by:
getHeader in interface HttpServletResponse
Returns:

getHeaders

public java.util.Collection<java.lang.String> getHeaders(java.lang.String name)
Description copied from interface: HttpServletResponse
Returns an Iterable for header values with a given name

Specified by:
getHeaders in interface HttpServletResponse
Returns:

getHeaderNames

public java.util.Collection<java.lang.String> getHeaderNames()
Description copied from interface: HttpServletResponse
Returns an Iterable for header names set via HttpServletResponse.setHeader(java.lang.String, java.lang.String), HttpServletResponse.addHeader(java.lang.String, java.lang.String), HttpServletResponse.setDateHeader(java.lang.String, long), HttpServletResponse.addDateHeader(java.lang.String, long), HttpServletResponse.setIntHeader(java.lang.String, int), or HttpServletResponse.addIntHeader(java.lang.String, int), respectively.

Specified by:
getHeaderNames in interface HttpServletResponse
Returns:

getResponseStream

public AbstractResponseStream getResponseStream()
Specified by:
getResponseStream in interface CauchoResponse

setResponseStream

public void setResponseStream(AbstractResponseStream os)
Specified by:
setResponseStream in interface CauchoResponse

isCauchoResponseStream

public boolean isCauchoResponseStream()
Specified by:
isCauchoResponseStream in interface CauchoResponse

setFooter

public void setFooter(java.lang.String key,
                      java.lang.String value)
Specified by:
setFooter in interface CauchoResponse

addFooter

public void addFooter(java.lang.String key,
                      java.lang.String value)
Specified by:
addFooter in interface CauchoResponse

close

public void close()
           throws java.io.IOException
Specified by:
close in interface CauchoResponse
Throws:
java.io.IOException

getForbidForward

public boolean getForbidForward()
Specified by:
getForbidForward in interface CauchoResponse

setForbidForward

public void setForbidForward(boolean forbid)
Specified by:
setForbidForward in interface CauchoResponse

getStatusMessage

public java.lang.String getStatusMessage()
Specified by:
getStatusMessage in interface CauchoResponse

hasError

public boolean hasError()
Specified by:
hasError in interface CauchoResponse

setHasError

public void setHasError(boolean error)
Specified by:
setHasError in interface CauchoResponse

setSessionId

public void setSessionId(java.lang.String id)
Specified by:
setSessionId in interface CauchoResponse

killCache

public void killCache()
Specified by:
killCache in interface CauchoResponse

completeCache

public void completeCache()
Specified by:
completeCache in interface CauchoResponse
Overrides:
completeCache in class AbstractCauchoResponse

setNoCache

public void setNoCache(boolean killCache)
Specified by:
setNoCache in interface CauchoResponse

setPrivateCache

public void setPrivateCache(boolean isPrivate)
Specified by:
setPrivateCache in interface CauchoResponse

isNoCacheUnlessVary

public boolean isNoCacheUnlessVary()
Specified by:
isNoCacheUnlessVary in interface CauchoResponse

getCauchoResponse

public CauchoResponse getCauchoResponse()

getAbstractHttpResponse

public AbstractHttpResponse getAbstractHttpResponse()
Specified by:
getAbstractHttpResponse in interface CauchoResponse

setCacheInvocation

public void setCacheInvocation(AbstractCacheFilterChain cacheFilterChain)
Specified by:
setCacheInvocation in interface CauchoResponse

setMatchCacheEntry

public void setMatchCacheEntry(AbstractCacheEntry cacheEntry)

getResponse

public ServletResponse getResponse()
Description copied from interface: CauchoResponse
Return wrapped response

Specified by:
getResponse in interface CauchoResponse

setForwardEnclosed

public void setForwardEnclosed(boolean isForwardEnclosed)
Specified by:
setForwardEnclosed in interface CauchoResponse

isForwardEnclosed

public boolean isForwardEnclosed()
Specified by:
isForwardEnclosed in interface CauchoResponse

toString

public java.lang.String toString()
Overrides:
toString in class AbstractCauchoResponse