com.caucho.server.http
Class CauchoDispatchResponse

java.lang.Object
  extended by com.caucho.server.http.AbstractCauchoResponse
      extended by com.caucho.server.http.CauchoDispatchResponse
All Implemented Interfaces:
CauchoResponse, HttpServletResponse, ServletResponse

public class CauchoDispatchResponse
extends AbstractCauchoResponse


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
CauchoDispatchResponse()
           
CauchoDispatchResponse(CauchoRequest request)
           
CauchoDispatchResponse(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 isCaching()
           
 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 setContentLength(long length)
           
 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
 

Constructor Detail

CauchoDispatchResponse

public CauchoDispatchResponse()

CauchoDispatchResponse

public CauchoDispatchResponse(CauchoRequest request)

CauchoDispatchResponse

public CauchoDispatchResponse(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");
 

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.


setContentLength

public void setContentLength(long length)

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.


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.


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".


getLocale

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


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.

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.

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.

Parameters:
size - the new output buffer size.

getBufferSize

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


flushBuffer

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

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.


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.


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.


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.


setStatus

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

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

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

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.

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.

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.

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

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);
 

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.

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.

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.

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.


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.

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()

Parameters:
name - the url to encode
Returns:
a url with session information encoded

setStatus

public void setStatus(int sc,
                      java.lang.String msg)

encodeUrl

public java.lang.String encodeUrl(java.lang.String url)

encodeRedirectUrl

public java.lang.String encodeRedirectUrl(java.lang.String url)

getStatus

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

Returns:

getHeader

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

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

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.

Returns:

getResponseStream

public AbstractResponseStream getResponseStream()

setResponseStream

public void setResponseStream(AbstractResponseStream os)

isCauchoResponseStream

public boolean isCauchoResponseStream()

setFooter

public void setFooter(java.lang.String key,
                      java.lang.String value)

addFooter

public void addFooter(java.lang.String key,
                      java.lang.String value)

close

public void close()
           throws java.io.IOException
Throws:
java.io.IOException

getForbidForward

public boolean getForbidForward()

setForbidForward

public void setForbidForward(boolean forbid)

getStatusMessage

public java.lang.String getStatusMessage()

hasError

public boolean hasError()

setHasError

public void setHasError(boolean error)

setSessionId

public void setSessionId(java.lang.String id)

killCache

public void killCache()

completeCache

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

setNoCache

public void setNoCache(boolean killCache)

setPrivateCache

public void setPrivateCache(boolean isPrivate)

isNoCacheUnlessVary

public boolean isNoCacheUnlessVary()

getCauchoResponse

public CauchoResponse getCauchoResponse()

getAbstractHttpResponse

public AbstractHttpResponse getAbstractHttpResponse()

setCacheInvocation

public void setCacheInvocation(AbstractCacheFilterChain cacheFilterChain)

isCaching

public boolean isCaching()

setMatchCacheEntry

public void setMatchCacheEntry(AbstractCacheEntry cacheEntry)

getResponse

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


setForwardEnclosed

public void setForwardEnclosed(boolean isForwardEnclosed)

isForwardEnclosed

public boolean isForwardEnclosed()

toString

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