com.caucho.server.connection
Class AbstractHttpResponse

java.lang.Object
  extended by com.caucho.server.connection.AbstractHttpResponse
All Implemented Interfaces:
CauchoResponse, HttpServletResponse, ServletResponse
Direct Known Subclasses:
HmuxResponse, HttpResponse, StubServletResponse

public abstract class AbstractHttpResponse
extends java.lang.Object
implements CauchoResponse

Encapsulates the servlet response, controlling response headers and the response stream.


Field Summary
protected  QDate _calendar
           
protected  CharBuffer _cb
           
protected  java.lang.String _charEncoding
           
protected  long _contentLength
           
protected  java.lang.String _contentPrefix
           
protected  java.lang.String _contentType
           
protected  java.util.ArrayList<Cookie> _cookiesOut
           
protected  boolean _disableCaching
           
protected  boolean _disableHeaders
           
protected  java.util.ArrayList<java.lang.String> _footerKeys
           
protected  java.util.ArrayList<java.lang.String> _footerValues
           
protected  boolean _forbidForward
           
protected  boolean _hasCharEncoding
           
protected  boolean _hasError
           
protected  boolean _hasOutputStream
           
protected  boolean _hasSentLog
           
protected  boolean _hasWriter
           
protected  char[] _headerBuffer
           
protected static CaseInsensitiveIntMap _headerCodes
           
protected  java.util.ArrayList<java.lang.String> _headerKeys
           
protected  java.util.ArrayList<java.lang.String> _headerValues
           
protected  boolean _isClosed
           
protected  boolean _isNoCache
           
protected  boolean _isTopCache
           
protected  CauchoRequest _originalRequest
           
protected  WriteStream _rawWrite
           
protected  CauchoRequest _request
           
protected  int _statusCode
           
protected  java.lang.String _statusMessage
           
protected static int HEADER_CACHE_CONTROL
           
protected static int HEADER_CONNECTION
           
protected static int HEADER_CONTENT_LENGTH
           
protected static int HEADER_CONTENT_TYPE
           
protected static int HEADER_DATE
           
protected static int HEADER_SERVER
           
protected static java.util.logging.Logger log
           
 
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_UNAUTHORIZED, SC_UNSUPPORTED_MEDIA_TYPE, SC_USE_PROXY_TYPE
 
Constructor Summary
protected AbstractHttpResponse()
           
protected AbstractHttpResponse(CauchoRequest request)
           
 
Method Summary
 void addCookie(Cookie cookie)
          Adds a cookie to the response.
 void addDateHeader(java.lang.String key, long value)
          Convenience for adding a date header.
 void addFooter(java.lang.String key, java.lang.String value)
          Adds a new footer.
 void addHeader(java.lang.String key, java.lang.String value)
          Adds a new header.
 void addIntHeader(java.lang.String key, int value)
          Convenience for adding an integer header.
 void clearBuffer()
           
 void close()
          Closes the request.
 boolean containsHeader(java.lang.String name)
          Returns true if the response already contains the named header.
protected  AbstractResponseStream createResponseStream()
           
 void disable()
          Disables the response
 boolean disableCaching(boolean disable)
           
 boolean disableHeaders(boolean disable)
           
 void enable()
          Enables the response
 java.lang.String encodeRedirectUrl(java.lang.String string)
          Deprecated.  
 java.lang.String encodeRedirectURL(java.lang.String string)
          Encodes session information in a URL suitable for sendRedirect()
 java.lang.String encodeUrl(java.lang.String string)
          Deprecated.  
 java.lang.String encodeURL(java.lang.String string)
          Encode the URL with the session jd.
 boolean fillCookie(CharBuffer cb, Cookie cookie, long date, int version, boolean isCookie2)
          Fills the response for a cookie
 void finish()
          Complete the request.
 void flushBuffer()
          Flushes the buffer to the client.
 void flushHeader()
           
protected  void free()
           
 int getBufferSize()
          Returns the size of the output buffer.
protected  QDate getCalendar()
           
 java.lang.String getCharacterEncoding()
          Gets the character encoding.
 int getContentLength()
          Returns the number of bytes sent to the output.
 long getContentLengthHeader()
          Returns the value of the content-length header.
 java.lang.String getContentType()
          Gets the content type.
protected  ConnectionController getController()
           
 Cookie getCookie(java.lang.String name)
           
 java.util.ArrayList getCookies()
           
 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 name)
          Returns the value of an already set output header.
 java.util.Locale getLocale()
          Returns the output locale.
 java.io.PrintWriter getNextWriter()
          Returns the parent writer.
 CauchoRequest getOriginalRequest()
          Returns the corresponding original
 AbstractResponseStream getOriginalStream()
          Gets the response stream.
 ServletOutputStream getOutputStream()
          Returns the ServletOutputStream for the response.
 boolean getPrivateCache()
          Returns the value of the private cache.
 WriteStream getRawOutput()
          Switch to raw socket mode.
 int getRemaining()
           
 CauchoRequest getRequest()
          Returns the corresponding request.
 ServletResponse getResponse()
          Returns the next response.
 AbstractResponseStream getResponseStream()
          Gets the response stream.
 int getStatusCode()
           
 java.lang.String getStatusMessage()
           
 java.io.PrintWriter getWriter()
          Returns a PrintWriter for the response.
 boolean hasError()
          Returns true if we're processing an error.
 void init(CauchoRequest request)
          Initialize the response for a new request.
 void init(WriteStream stream)
          Initialize the response for a new request.
 boolean isCacheHit()
          Set true for a cache hit.
 boolean isCauchoResponseStream()
          Returns true for a Caucho response stream.
 boolean isClosed()
          Returns true for closed requests.
 boolean isCommitted()
          Returns true if some data has been sent to the browser.
 boolean isDisabled()
          Returns true if the response is disabled
protected  boolean isHead()
          For a HEAD request, the response stream should write no data.
 boolean isHeaderWritten()
          Returns true if the headers have been written.
 boolean isIgnoreClientDisconnect()
          If set true, client disconnect exceptions are no propagated to the server code.
 boolean isNoCache()
          Returns true if the page is non-cacheable
protected  boolean isPrivateCache()
          Returns true if the response should contain a Cache-Control: private
 boolean isTop()
          Return true for the top request.
 void killCache()
          Set if the page is non-cacheable.
 void killCaching()
           
 void removeHeader(java.lang.String key)
           
 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 code)
          Sends an HTTP error page based on the status code
 void sendError(int code, java.lang.String value)
          Sends an HTTP error to the browser.
 void sendRedirect(java.lang.String url)
          Sends a redirect to the browser.
 void setBufferSize(int size)
          Sets the output buffer size to size.
 void setCacheHit(boolean isHit)
          Set true for a cache hit.
 void setCacheInvocation(AbstractCacheFilterChain cacheInvocation)
          Sets the cache invocation to indicate that the response might be cacheable.
 void setCharacterEncoding(java.lang.String encoding)
          Sets the character encoding.
 void setContentLength(int length)
          Sets the content length of the result.
 void setContentType(java.lang.String value)
          Sets the browser content type.
 void setDateHeader(java.lang.String name, long value)
          Convenience for setting a date header.
 void setDisableAutoFlush(boolean disable)
           
 void setFlushBuffer(FlushBuffer flushBuffer)
          Sets the flush buffer
 void setFooter(java.lang.String key, java.lang.String value)
          Sets a footer, replacing an already-existing footer
 void setForbidForward(boolean forbid)
          When set to true, RequestDispatcher.forward() is disallowed on this stream.
 void setHasError(boolean hasError)
          Set to true while processing an error.
 void setHeader(java.lang.String key, java.lang.String value)
          Sets a header, replacing an already-existing header.
 void setHeaderWritten(boolean isWritten)
          Returns true if the headers have been written.
 void setIntHeader(java.lang.String name, int value)
          Convenience for setting an integer header.
 void setLocale(java.util.Locale locale)
          Sets the output locale.
 void setMatchCacheEntry(AbstractCacheEntry entry)
          Sets the cache entry so we can use it if the servlet returns not_modified response.
 void setNoCache(boolean isNoCache)
          Set if the page is non-cacheable.
 void setPrivateCache(boolean isPrivate)
          Sets true if the cache is only for the browser, but not Resin's cache or proxies.
 void setPrivateOrResinCache(boolean isPrivate)
          Sets true if the cache is only for the browser and Resin's cache but not proxies.
 void setRequest(CauchoRequest req)
          Sets the corresponding request.
 void setResponseStream(AbstractResponseStream responseStream)
          Sets the ResponseStream
 void setSessionId(java.lang.String id)
           
protected  boolean setSpecial(java.lang.String key, java.lang.String value)
          Special processing for a special value.
 void setStatus(int code)
          Sets the HTTP status
 void setStatus(int code, java.lang.String message)
           
 void setTopCache(boolean isTopCache)
           
 void start()
          Initializes the Response at the beginning of the request.
protected  boolean startCaching(boolean isByte)
          Called to start caching.
 void switchToRaw()
          Switch to raw socket mode.
 TcpDuplexController upgradeProtocol(TcpDuplexHandler handler)
           
protected  void writeContinueInt(WriteStream os)
          Writes the continue
protected  boolean writeHeaders(WriteStream os, int length)
          Writes the headers to the stream.
protected abstract  boolean writeHeadersInt(WriteStream os, int length, boolean isHead)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

protected static final java.util.logging.Logger log

_headerCodes

protected static final CaseInsensitiveIntMap _headerCodes

HEADER_CACHE_CONTROL

protected static final int HEADER_CACHE_CONTROL
See Also:
Constant Field Values

HEADER_CONTENT_TYPE

protected static final int HEADER_CONTENT_TYPE
See Also:
Constant Field Values

HEADER_CONTENT_LENGTH

protected static final int HEADER_CONTENT_LENGTH
See Also:
Constant Field Values

HEADER_DATE

protected static final int HEADER_DATE
See Also:
Constant Field Values

HEADER_SERVER

protected static final int HEADER_SERVER
See Also:
Constant Field Values

HEADER_CONNECTION

protected static final int HEADER_CONNECTION
See Also:
Constant Field Values

_originalRequest

protected CauchoRequest _originalRequest

_request

protected CauchoRequest _request

_statusCode

protected int _statusCode

_statusMessage

protected java.lang.String _statusMessage

_contentType

protected java.lang.String _contentType

_contentPrefix

protected java.lang.String _contentPrefix

_charEncoding

protected java.lang.String _charEncoding

_hasCharEncoding

protected boolean _hasCharEncoding

_headerKeys

protected final java.util.ArrayList<java.lang.String> _headerKeys

_headerValues

protected final java.util.ArrayList<java.lang.String> _headerValues

_footerKeys

protected final java.util.ArrayList<java.lang.String> _footerKeys

_footerValues

protected final java.util.ArrayList<java.lang.String> _footerValues

_cookiesOut

protected final java.util.ArrayList<Cookie> _cookiesOut

_rawWrite

protected WriteStream _rawWrite

_calendar

protected final QDate _calendar

_cb

protected final CharBuffer _cb

_headerBuffer

protected final char[] _headerBuffer

_disableHeaders

protected boolean _disableHeaders

_disableCaching

protected boolean _disableCaching

_contentLength

protected long _contentLength

_isClosed

protected boolean _isClosed

_hasSentLog

protected boolean _hasSentLog

_hasWriter

protected boolean _hasWriter

_hasOutputStream

protected boolean _hasOutputStream

_isNoCache

protected boolean _isNoCache

_isTopCache

protected boolean _isTopCache

_forbidForward

protected boolean _forbidForward

_hasError

protected boolean _hasError
Constructor Detail

AbstractHttpResponse

protected AbstractHttpResponse()

AbstractHttpResponse

protected AbstractHttpResponse(CauchoRequest request)
Method Detail

createResponseStream

protected AbstractResponseStream createResponseStream()

isIgnoreClientDisconnect

public boolean isIgnoreClientDisconnect()
If set true, client disconnect exceptions are no propagated to the server code.


isTop

public boolean isTop()
Return true for the top request.


getResponse

public ServletResponse getResponse()
Returns the next response.


init

public void init(WriteStream stream)
Initialize the response for a new request.

Parameters:
stream - the underlying output stream.

init

public void init(CauchoRequest request)
Initialize the response for a new request.

Parameters:
request - the matching request.

getRequest

public CauchoRequest getRequest()
Returns the corresponding request.


setRequest

public void setRequest(CauchoRequest req)
Sets the corresponding request.


getOriginalRequest

public CauchoRequest getOriginalRequest()
Returns the corresponding original


close

public void close()
           throws java.io.IOException
Closes the request.

Specified by:
close in interface CauchoResponse
Throws:
java.io.IOException

isClosed

public boolean isClosed()
Returns true for closed requests.


start

public void start()
           throws java.io.IOException
Initializes the Response at the beginning of the request.

Throws:
java.io.IOException

isHead

protected final boolean isHead()
For a HEAD request, the response stream should write no data.


setCacheHit

public void setCacheHit(boolean isHit)
Set true for a cache hit.


isCacheHit

public boolean isCacheHit()
Set true for a cache hit.


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

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

setMatchCacheEntry

public void setMatchCacheEntry(AbstractCacheEntry entry)
Sets the cache entry so we can use it if the servlet returns not_modified response.

Parameters:
entry - the saved cache entry

setCacheInvocation

public void setCacheInvocation(AbstractCacheFilterChain cacheInvocation)
Sets the cache invocation to indicate that the response might be cacheable.


setTopCache

public void setTopCache(boolean isTopCache)

setStatus

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

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

setStatus

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

getStatusCode

public int getStatusCode()
Specified by:
getStatusCode in interface CauchoResponse

getStatusMessage

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

sendError

public void sendError(int code)
               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:
code - the HTTP status code
Throws:
java.io.IOException

sendError

public void sendError(int code,
                      java.lang.String value)
               throws java.io.IOException
Sends an HTTP error to the browser.

Specified by:
sendError in interface HttpServletResponse
Parameters:
code - the HTTP error code
value - a string message
Throws:
java.io.IOException

sendRedirect

public void sendRedirect(java.lang.String url)
                  throws java.io.IOException
Sends a redirect to the browser. If the URL is relative, it gets combined with the current url.

Specified by:
sendRedirect in interface HttpServletResponse
Parameters:
url - the possibly relative url to send to the browser
Throws:
java.io.IOException

switchToRaw

public void switchToRaw()
                 throws java.io.IOException
Switch to raw socket mode.

Throws:
java.io.IOException

getRawOutput

public WriteStream getRawOutput()
                         throws java.io.IOException
Switch to raw socket mode.

Throws:
java.io.IOException

containsHeader

public boolean containsHeader(java.lang.String name)
Returns true if the response already contains the named header.

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

getHeader

public java.lang.String getHeader(java.lang.String name)
Returns the value of an already set output header.

Specified by:
getHeader in interface CauchoResponse
Parameters:
name - name of the header to get.

setHeader

public void setHeader(java.lang.String key,
                      java.lang.String value)
Sets a header, replacing an already-existing header.

Specified by:
setHeader in interface HttpServletResponse
Parameters:
key - the header key to set.
value - the header value to set.

addHeader

public void addHeader(java.lang.String key,
                      java.lang.String value)
Adds a new header. If an old header with that name exists, both headers are output.

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

setSpecial

protected boolean setSpecial(java.lang.String key,
                             java.lang.String value)
Special processing for a special value.


removeHeader

public void removeHeader(java.lang.String key)

setIntHeader

public void setIntHeader(java.lang.String name,
                         int value)
Convenience for setting an integer header. An old header with the same name will be replaced.

Specified by:
setIntHeader in interface HttpServletResponse
Parameters:
name - the header name.
value - an integer to be converted to a string for the header.

addIntHeader

public void addIntHeader(java.lang.String key,
                         int value)
Convenience for adding an integer header. If an old header already exists, both will be sent to the browser.

Specified by:
addIntHeader in interface HttpServletResponse
Parameters:
key - the header name.
value - an integer to be converted to a string for the header.

setDateHeader

public void setDateHeader(java.lang.String name,
                          long value)
Convenience for setting a date header. An old header with the same name will be replaced.

Specified by:
setDateHeader in interface HttpServletResponse
Parameters:
name - the header name.
value - an time in milliseconds to be converted to a date string.

addDateHeader

public void addDateHeader(java.lang.String key,
                          long value)
Convenience for adding a date header. If an old header with the same name exists, both will be displayed.

Specified by:
addDateHeader in interface HttpServletResponse
Parameters:
key - the header name.
value - an time in milliseconds to be converted to a date string.

setContentLength

public void setContentLength(int length)
Sets the content length of the result. In general, Resin will handle the content length, but for things like long downloads adding the length will give a valuable hint to the browser.

Specified by:
setContentLength in interface ServletResponse
Parameters:
length - the length of the content.

getContentLengthHeader

public long getContentLengthHeader()
Returns the value of the content-length header.


setContentType

public void setContentType(java.lang.String value)
Sets the browser content type. If the value contains a charset, the output encoding will be changed to match.

For example, to set the output encoding to use UTF-8 instead of the default ISO-8859-1 (Latin-1), use the following:

 setContentType("text/html; charset=UTF-8");
 

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

getContentType

public java.lang.String getContentType()
Gets the content type.

Specified by:
getContentType in interface ServletResponse

getCharacterEncoding

public java.lang.String getCharacterEncoding()
Gets the character encoding.

Specified by:
getCharacterEncoding in interface ServletResponse

setCharacterEncoding

public void setCharacterEncoding(java.lang.String encoding)
Sets the character encoding.

Specified by:
setCharacterEncoding in interface ServletResponse

addCookie

public void addCookie(Cookie cookie)
Adds a cookie to the response.

Specified by:
addCookie in interface HttpServletResponse
Parameters:
cookie - the response cookie

getCookie

public Cookie getCookie(java.lang.String name)

getCookies

public java.util.ArrayList getCookies()

setSessionId

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

setFooter

public void setFooter(java.lang.String key,
                      java.lang.String value)
Sets a footer, replacing an already-existing footer

Specified by:
setFooter in interface CauchoResponse
Parameters:
key - the header key to set.
value - the header value to set.

addFooter

public void addFooter(java.lang.String key,
                      java.lang.String value)
Adds a new footer. If an old footer with that name exists, both footers are output.

Specified by:
addFooter in interface CauchoResponse
Parameters:
key - the footer key.
value - the footer value.

setResponseStream

public void setResponseStream(AbstractResponseStream responseStream)
Sets the ResponseStream

Specified by:
setResponseStream in interface CauchoResponse

getResponseStream

public AbstractResponseStream getResponseStream()
Gets the response stream.

Specified by:
getResponseStream in interface CauchoResponse

getOriginalStream

public AbstractResponseStream getOriginalStream()
Gets the response stream.


isCauchoResponseStream

public boolean isCauchoResponseStream()
Returns true for a Caucho response stream.

Specified by:
isCauchoResponseStream in interface CauchoResponse

getOutputStream

public ServletOutputStream getOutputStream()
                                    throws java.io.IOException
Returns the ServletOutputStream for the response.

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

setFlushBuffer

public void setFlushBuffer(FlushBuffer flushBuffer)
Sets the flush buffer

Specified by:
setFlushBuffer in interface CauchoResponse

getFlushBuffer

public FlushBuffer getFlushBuffer()
Gets the flush buffer

Specified by:
getFlushBuffer in interface CauchoResponse

getWriter

public java.io.PrintWriter getWriter()
                              throws java.io.IOException
Returns a PrintWriter for the response.

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

getNextWriter

public java.io.PrintWriter getNextWriter()
Returns the parent writer.


encodeURL

public java.lang.String encodeURL(java.lang.String string)
Encode the URL with the session jd.

Specified by:
encodeURL in interface HttpServletResponse
Parameters:
string - the url to be encoded
Returns:
the encoded url

encodeRedirectURL

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

Specified by:
encodeRedirectURL in interface HttpServletResponse
Returns:
a url with session information encoded

encodeRedirectUrl

public java.lang.String encodeRedirectUrl(java.lang.String string)
Deprecated. 

Specified by:
encodeRedirectUrl in interface HttpServletResponse

encodeUrl

public java.lang.String encodeUrl(java.lang.String string)
Deprecated. 

Specified by:
encodeUrl in interface HttpServletResponse

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

flushHeader

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

setDisableAutoFlush

public void setDisableAutoFlush(boolean disable)

isCommitted

public boolean isCommitted()
Returns true if some data has been sent to the browser.

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

clearBuffer

public void clearBuffer()

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

getRemaining

public int getRemaining()

getContentLength

public int getContentLength()
Returns the number of bytes sent to the output.


disable

public void disable()
Disables the response

Specified by:
disable in interface ServletResponse
Since:
Servlet 3.0

enable

public void enable()
Enables the response

Specified by:
enable in interface ServletResponse
Since:
Servlet 3.0

isDisabled

public boolean isDisabled()
Returns true if the response is disabled

Specified by:
isDisabled in interface ServletResponse
Since:
Servlet 3.0

disableHeaders

public boolean disableHeaders(boolean disable)
Specified by:
disableHeaders in interface CauchoResponse

disableCaching

public boolean disableCaching(boolean disable)

isHeaderWritten

public final boolean isHeaderWritten()
Returns true if the headers have been written.


setHeaderWritten

public final void setHeaderWritten(boolean isWritten)
Returns true if the headers have been written.


writeContinueInt

protected void writeContinueInt(WriteStream os)
                         throws java.io.IOException
Writes the continue

Throws:
java.io.IOException

writeHeaders

protected boolean writeHeaders(WriteStream os,
                               int length)
                        throws java.io.IOException
Writes the headers to the stream. Called prior to the first flush of data.

Parameters:
os - browser stream.
length - length of the response if known, or -1 is unknown.
Returns:
true if the content is chunked.
Throws:
java.io.IOException

startCaching

protected boolean startCaching(boolean isByte)
Called to start caching.


writeHeadersInt

protected abstract boolean writeHeadersInt(WriteStream os,
                                           int length,
                                           boolean isHead)
                                    throws java.io.IOException
Throws:
java.io.IOException

setPrivateCache

public void setPrivateCache(boolean isPrivate)
Sets true if the cache is only for the browser, but not Resin's cache or proxies.

Since proxy caching also caches headers, cached pages with session ids can't be cached in the browser. XXX: but doesn't this just mean that Resin shouldn't send the session information back if the page is cached? Because a second request where everything is identical would see the same response except for the cookies.

Specified by:
setPrivateCache in interface CauchoResponse

setPrivateOrResinCache

public void setPrivateOrResinCache(boolean isPrivate)
Sets true if the cache is only for the browser and Resin's cache but not proxies.


getPrivateCache

public boolean getPrivateCache()
Returns the value of the private cache.


isPrivateCache

protected boolean isPrivateCache()
Returns true if the response should contain a Cache-Control: private


setNoCache

public void setNoCache(boolean isNoCache)
Set if the page is non-cacheable.

Specified by:
setNoCache in interface CauchoResponse

isNoCache

public boolean isNoCache()
Returns true if the page is non-cacheable


killCache

public void killCache()
Set if the page is non-cacheable.

Specified by:
killCache in interface