|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.caucho.server.connection.AbstractHttpResponse
public abstract class AbstractHttpResponse
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
|
| 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 |
|---|
protected static final java.util.logging.Logger log
protected static final CaseInsensitiveIntMap _headerCodes
protected static final int HEADER_CACHE_CONTROL
protected static final int HEADER_CONTENT_TYPE
protected static final int HEADER_CONTENT_LENGTH
protected static final int HEADER_DATE
protected static final int HEADER_SERVER
protected static final int HEADER_CONNECTION
protected CauchoRequest _originalRequest
protected CauchoRequest _request
protected int _statusCode
protected java.lang.String _statusMessage
protected java.lang.String _contentType
protected java.lang.String _contentPrefix
protected java.lang.String _charEncoding
protected boolean _hasCharEncoding
protected final java.util.ArrayList<java.lang.String> _headerKeys
protected final java.util.ArrayList<java.lang.String> _headerValues
protected final java.util.ArrayList<java.lang.String> _footerKeys
protected final java.util.ArrayList<java.lang.String> _footerValues
protected final java.util.ArrayList<Cookie> _cookiesOut
protected WriteStream _rawWrite
protected final QDate _calendar
protected final CharBuffer _cb
protected final char[] _headerBuffer
protected boolean _disableHeaders
protected boolean _disableCaching
protected long _contentLength
protected boolean _isClosed
protected boolean _hasSentLog
protected boolean _hasWriter
protected boolean _hasOutputStream
protected boolean _isNoCache
protected boolean _isTopCache
protected boolean _forbidForward
protected boolean _hasError
| Constructor Detail |
|---|
protected AbstractHttpResponse()
protected AbstractHttpResponse(CauchoRequest request)
| Method Detail |
|---|
protected AbstractResponseStream createResponseStream()
public boolean isIgnoreClientDisconnect()
public boolean isTop()
public ServletResponse getResponse()
public void init(WriteStream stream)
stream - the underlying output stream.public void init(CauchoRequest request)
request - the matching request.public CauchoRequest getRequest()
public void setRequest(CauchoRequest req)
public CauchoRequest getOriginalRequest()
public void close()
throws java.io.IOException
close in interface CauchoResponsejava.io.IOExceptionpublic boolean isClosed()
public void start()
throws java.io.IOException
java.io.IOExceptionprotected final boolean isHead()
public void setCacheHit(boolean isHit)
public boolean isCacheHit()
public void setForbidForward(boolean forbid)
setForbidForward in interface CauchoResponsepublic boolean getForbidForward()
getForbidForward in interface CauchoResponsepublic void setHasError(boolean hasError)
setHasError in interface CauchoResponsepublic boolean hasError()
hasError in interface CauchoResponsepublic void setMatchCacheEntry(AbstractCacheEntry entry)
entry - the saved cache entrypublic void setCacheInvocation(AbstractCacheFilterChain cacheInvocation)
public void setTopCache(boolean isTopCache)
public void setStatus(int code)
HttpServletResponse
setStatus in interface HttpServletResponsecode - the HTTP status code
public void setStatus(int code,
java.lang.String message)
setStatus in interface HttpServletResponsepublic int getStatusCode()
getStatusCode in interface CauchoResponsepublic java.lang.String getStatusMessage()
getStatusMessage in interface CauchoResponse
public void sendError(int code)
throws java.io.IOException
HttpServletResponse
sendError in interface HttpServletResponsecode - the HTTP status code
java.io.IOException
public void sendError(int code,
java.lang.String value)
throws java.io.IOException
sendError in interface HttpServletResponsecode - the HTTP error codevalue - a string message
java.io.IOException
public void sendRedirect(java.lang.String url)
throws java.io.IOException
sendRedirect in interface HttpServletResponseurl - the possibly relative url to send to the browser
java.io.IOException
public void switchToRaw()
throws java.io.IOException
java.io.IOException
public WriteStream getRawOutput()
throws java.io.IOException
java.io.IOExceptionpublic boolean containsHeader(java.lang.String name)
containsHeader in interface HttpServletResponsename - name of the header to test.public java.lang.String getHeader(java.lang.String name)
getHeader in interface CauchoResponsename - name of the header to get.
public void setHeader(java.lang.String key,
java.lang.String value)
setHeader in interface HttpServletResponsekey - the header key to set.value - the header value to set.
public void addHeader(java.lang.String key,
java.lang.String value)
addHeader in interface HttpServletResponsekey - the header key.value - the header value.
protected boolean setSpecial(java.lang.String key,
java.lang.String value)
public void removeHeader(java.lang.String key)
public void setIntHeader(java.lang.String name,
int value)
setIntHeader in interface HttpServletResponsename - the header name.value - an integer to be converted to a string for the header.
public void addIntHeader(java.lang.String key,
int value)
addIntHeader in interface HttpServletResponsekey - the header name.value - an integer to be converted to a string for the header.
public void setDateHeader(java.lang.String name,
long value)
setDateHeader in interface HttpServletResponsename - the header name.value - an time in milliseconds to be converted to a date string.
public void addDateHeader(java.lang.String key,
long value)
addDateHeader in interface HttpServletResponsekey - the header name.value - an time in milliseconds to be converted to a date string.public void setContentLength(int length)
setContentLength in interface ServletResponselength - the length of the content.public long getContentLengthHeader()
public void setContentType(java.lang.String value)
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");
setContentType in interface ServletResponsevalue - the mime type of the outputpublic java.lang.String getContentType()
getContentType in interface ServletResponsepublic java.lang.String getCharacterEncoding()
getCharacterEncoding in interface ServletResponsepublic void setCharacterEncoding(java.lang.String encoding)
setCharacterEncoding in interface ServletResponsepublic void addCookie(Cookie cookie)
addCookie in interface HttpServletResponsecookie - the response cookiepublic Cookie getCookie(java.lang.String name)
public java.util.ArrayList getCookies()
public void setSessionId(java.lang.String id)
setSessionId in interface CauchoResponse
public void setFooter(java.lang.String key,
java.lang.String value)
setFooter in interface CauchoResponsekey - the header key to set.value - the header value to set.
public void addFooter(java.lang.String key,
java.lang.String value)
addFooter in interface CauchoResponsekey - the footer key.value - the footer value.public void setResponseStream(AbstractResponseStream responseStream)
setResponseStream in interface CauchoResponsepublic AbstractResponseStream getResponseStream()
getResponseStream in interface CauchoResponsepublic AbstractResponseStream getOriginalStream()
public boolean isCauchoResponseStream()
isCauchoResponseStream in interface CauchoResponse
public ServletOutputStream getOutputStream()
throws java.io.IOException
getOutputStream in interface ServletResponsejava.io.IOExceptionpublic void setFlushBuffer(FlushBuffer flushBuffer)
setFlushBuffer in interface CauchoResponsepublic FlushBuffer getFlushBuffer()
getFlushBuffer in interface CauchoResponse
public java.io.PrintWriter getWriter()
throws java.io.IOException
getWriter in interface ServletResponsejava.io.IOExceptionpublic java.io.PrintWriter getNextWriter()
public java.lang.String encodeURL(java.lang.String string)
encodeURL in interface HttpServletResponsestring - the url to be encoded
public java.lang.String encodeRedirectURL(java.lang.String string)
HttpServletResponsesendRedirect()
encodeRedirectURL in interface HttpServletResponsepublic java.lang.String encodeRedirectUrl(java.lang.String string)
encodeRedirectUrl in interface HttpServletResponsepublic java.lang.String encodeUrl(java.lang.String string)
encodeUrl in interface HttpServletResponsepublic void setBufferSize(int size)
ServletResponsesize. The servlet engine
may round the size up.
setBufferSize in interface ServletResponsesize - the new output buffer size.public int getBufferSize()
ServletResponse
getBufferSize in interface ServletResponse
public void flushBuffer()
throws java.io.IOException
ServletResponse
flushBuffer in interface ServletResponsejava.io.IOException
public void flushHeader()
throws java.io.IOException
java.io.IOExceptionpublic void setDisableAutoFlush(boolean disable)
public boolean isCommitted()
isCommitted in interface ServletResponsepublic void reset()
ServletResponsereset() after data has been committed is illegal.
reset in interface ServletResponsepublic void resetBuffer()
ServletResponsereset() after data has been committed is illegal.
resetBuffer in interface ServletResponsepublic void clearBuffer()
public void setLocale(java.util.Locale locale)
ServletResponse
setLocale in interface ServletResponsepublic java.util.Locale getLocale()
ServletResponse
getLocale in interface ServletResponsepublic int getRemaining()
public int getContentLength()
public void disable()
disable in interface ServletResponsepublic void enable()
enable in interface ServletResponsepublic boolean isDisabled()
isDisabled in interface ServletResponsepublic boolean disableHeaders(boolean disable)
disableHeaders in interface CauchoResponsepublic boolean disableCaching(boolean disable)
public final boolean isHeaderWritten()
public final void setHeaderWritten(boolean isWritten)
protected void writeContinueInt(WriteStream os)
throws java.io.IOException
java.io.IOException
protected boolean writeHeaders(WriteStream os,
int length)
throws java.io.IOException
os - browser stream.length - length of the response if known, or -1 is unknown.
java.io.IOExceptionprotected boolean startCaching(boolean isByte)
protected abstract boolean writeHeadersInt(WriteStream os,
int length,
boolean isHead)
throws java.io.IOException
java.io.IOExceptionpublic void setPrivateCache(boolean isPrivate)
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.
setPrivateCache in interface CauchoResponsepublic void setPrivateOrResinCache(boolean isPrivate)
public boolean getPrivateCache()
protected boolean isPrivateCache()
public void setNoCache(boolean isNoCache)
setNoCache in interface CauchoResponsepublic boolean isNoCache()
public void killCache()
killCache in interface