com.caucho.server.http
Class ResponseAdapter

java.lang.Object
  extended by com.caucho.server.http.ResponseWrapper
      extended by com.caucho.server.http.ResponseAdapter
All Implemented Interfaces:
CauchoResponse, HttpServletResponse, ServletResponse
Direct Known Subclasses:
DispatchResponse, ToCharResponseAdapter

public class ResponseAdapter
extends ResponseWrapper
implements CauchoResponse


Field Summary
 
Fields inherited from class com.caucho.server.http.ResponseWrapper
_response
 
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
protected ResponseAdapter()
           
 
Method Summary
 void addCookie(Cookie cookie)
          Sends a new cookie to the client.
 void addFooter(java.lang.String key, java.lang.String value)
           
 void close()
           
 void completeCache()
           
static ResponseAdapter create(HttpServletResponse response)
          Creates a new ResponseAdapter.
protected  AbstractResponseStream createWrapperResponseStream()
           
 boolean disableHeaders(boolean disable)
           
 void finish()
           
protected  void free()
          Clears the adapter.
static void free(ResponseAdapter resAdapt)
           
 int getBufferSize()
          Returns the size of the output buffer.
 CauchoResponse getCauchoResponse()
           
 FlushBuffer getFlushBuffer()
          Gets the flush buffer
 boolean getForbidForward()
          Returns true if RequestDispatcher.forward() is disallowed on this stream.
 java.lang.String getHeader(java.lang.String key)
          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
 ServletOutputStream getOutputStream()
          Returns an output stream for writing to the client.
 int getRemaining()
           
 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()
          Returns true if we're processing an error.
 void init(HttpServletResponse response)
           
 boolean isCauchoResponseStream()
           
 boolean isForwardEnclosed()
           
 boolean isNoCacheUnlessVary()
           
 boolean isTop()
           
 void killCache()
          Kills the cache for an error.
 void resetBuffer()
          Resets the output stream without clearing headers and the output buffer.
 void sendRedirect(java.lang.String url)
          Redirects the client to another page.
 void setBufferSize(int size)
          Sets the output buffer size to size.
 void setContentType(java.lang.String value)
          Sets the response content type.
 void setFlushBuffer(FlushBuffer flushBuffer)
          Sets the flush buffer
 void setFooter(java.lang.String key, java.lang.String value)
           
 void setForbidForward(boolean forbid)
          When set to true, RequestDispatcher.forward() is disallowed on this stream.
 void setForwardEnclosed(boolean isForwardEnclosed)
           
 void setHasError(boolean hasError)
          Set to true while processing an error.
 void setNoCache(boolean isPrivate)
          Sets no caching
 void setPrivateCache(boolean isPrivate)
          Sets private caching
 void setResponseStream(AbstractResponseStream responseStream)
           
 void setSessionId(java.lang.String id)
           
 void writeHeaders(int length)
           
 
Methods inherited from class com.caucho.server.http.ResponseWrapper
addDateHeader, addHeader, addIntHeader, containsHeader, disable, enable, encodeRedirectUrl, encodeRedirectURL, encodeUrl, encodeURL, flushBuffer, getAbstractHttpResponse, getCharacterEncoding, getContentType, getLocale, getResponse, isCommitted, isDisabled, reset, sendError, sendError, setCacheInvocation, setCharacterEncoding, setContentLength, setDateHeader, setHeader, setIntHeader, setLocale, setMatchCacheEntry, setResponse, setStatus, setStatus
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.caucho.server.http.CauchoResponse
getAbstractHttpResponse, getResponse, setCacheInvocation
 
Methods inherited from interface javax.servlet.http.HttpServletResponse
addDateHeader, addHeader, addIntHeader, containsHeader, encodeRedirectUrl, encodeRedirectURL, encodeUrl, encodeURL, sendError, sendError, setDateHeader, setHeader, setIntHeader, setStatus, setStatus
 
Methods inherited from interface javax.servlet.ServletResponse
flushBuffer, getCharacterEncoding, getContentType, getLocale, isCommitted, reset, setCharacterEncoding, setContentLength, setLocale
 

Constructor Detail

ResponseAdapter

protected ResponseAdapter()
Method Detail

create

public static ResponseAdapter create(HttpServletResponse response)
Creates a new ResponseAdapter.


createWrapperResponseStream

protected AbstractResponseStream createWrapperResponseStream()

init

public void init(HttpServletResponse response)

getResponseStream

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

isCauchoResponseStream

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

setResponseStream

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

isTop

public boolean isTop()

resetBuffer

public void resetBuffer()
Description copied from class: ResponseWrapper
Resets the output stream without clearing headers and the output buffer. Calling resetBuffer() after data has been committed is illegal.

Specified by:
resetBuffer in interface ServletResponse
Overrides:
resetBuffer in class ResponseWrapper

sendRedirect

public void sendRedirect(java.lang.String url)
                  throws java.io.IOException
Description copied from class: ResponseWrapper
Redirects the client to another page.

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

getBufferSize

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

Specified by:
getBufferSize in interface ServletResponse
Overrides:
getBufferSize in class ResponseWrapper

setBufferSize

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

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

getOutputStream

public ServletOutputStream getOutputStream()
                                    throws java.io.IOException
Description copied from class: ResponseWrapper
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
Overrides:
getOutputStream in class ResponseWrapper
Throws:
java.io.IOException

setFlushBuffer

public void setFlushBuffer(FlushBuffer flushBuffer)
Sets the flush buffer


getFlushBuffer

public FlushBuffer getFlushBuffer()
Gets the flush buffer


getWriter

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

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

setContentType

public void setContentType(java.lang.String value)
Description copied from class: ResponseWrapper
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
Overrides:
setContentType in class ResponseWrapper
Parameters:
value - the mime type of the output

addCookie

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

Specified by:
addCookie in interface HttpServletResponse
Overrides:
addCookie in class ResponseWrapper

getHeader

public java.lang.String getHeader(java.lang.String key)
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:

disableHeaders

public boolean disableHeaders(boolean disable)

setFooter

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

addFooter

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

getRemaining

public int getRemaining()

setForbidForward

public void setForbidForward(boolean forbid)
When set to true, RequestDispatcher.forward() is disallowed on this stream.

Specified by:
setForbidForward in interface CauchoResponse

getForbidForward

public boolean getForbidForward()
Returns true if RequestDispatcher.forward() is disallowed on this stream.

Specified by:
getForbidForward in interface CauchoResponse

getStatusMessage

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

setHasError

public void setHasError(boolean hasError)
Set to true while processing an error.

Specified by:
setHasError in interface CauchoResponse

hasError

public boolean hasError()
Returns true if we're processing an error.

Specified by:
hasError in interface CauchoResponse

killCache

public void killCache()
Kills the cache for an error.

Specified by:
killCache in interface CauchoResponse

setPrivateCache

public void setPrivateCache(boolean isPrivate)
Sets private caching

Specified by:
setPrivateCache in interface CauchoResponse

setNoCache

public void setNoCache(boolean isPrivate)
Sets no caching

Specified by:
setNoCache in interface CauchoResponse

setSessionId

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

isNoCacheUnlessVary

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

getCauchoResponse

public CauchoResponse getCauchoResponse()

finish

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

completeCache

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

close

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

getStatus

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

Specified by:
getStatus 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:

setForwardEnclosed

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

isForwardEnclosed

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

writeHeaders

public void writeHeaders(int length)
Specified by:
writeHeaders in interface CauchoResponse

free

public static void free(ResponseAdapter resAdapt)

free

protected void free()
Clears the adapter.