com.caucho.server.connection
Class StubServletResponse

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

public class StubServletResponse
extends AbstractHttpResponse


Field Summary
 
Fields inherited from class com.caucho.server.connection.AbstractHttpResponse
_calendar, _cb, _charEncoding, _contentLength, _contentPrefix, _contentType, _cookiesOut, _disableCaching, _disableHeaders, _footerKeys, _footerValues, _forbidForward, _hasCharEncoding, _hasError, _hasOutputStream, _hasSentLog, _hasWriter, _headerBuffer, _headerCodes, _headerKeys, _headerValues, _isClosed, _isNoCache, _isTopCache, _originalRequest, _rawWrite, _request, _statusCode, _statusMessage, HEADER_CACHE_CONTROL, HEADER_CONNECTION, HEADER_CONTENT_LENGTH, HEADER_CONTENT_TYPE, HEADER_DATE, HEADER_SERVER, 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
StubServletResponse()
           
 
Method Summary
 void addCookie(Cookie cookie)
          Adds a cookie to the response.
 void addDateHeader(java.lang.String header, long value)
          Convenience for adding a date header.
 void addHeader(java.lang.String header, java.lang.String value)
          Adds a new header.
 void addIntHeader(java.lang.String header, int value)
          Convenience for adding an integer header.
 void clearBuffer()
           
 void close()
          Closes the request.
 boolean containsHeader(java.lang.String header)
          Returns true if the response already contains the named header.
 boolean disableHeaders(boolean disable)
           
 java.lang.String encodeRedirectUrl(java.lang.String url)
           
 java.lang.String encodeRedirectURL(java.lang.String url)
          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)
          Encode the URL with the session jd.
 void flushBuffer()
          Flushes the buffer to the client.
 int getBufferSize()
          Returns the size of the output buffer.
 java.lang.String getCharacterEncoding()
          Gets the character encoding.
 boolean getForbidForward()
          Returns true if RequestDispatcher.forward() is disallowed on this stream.
 java.lang.String getHeader(java.lang.String key)
          Returns the value of an already set output header.
 java.util.Locale getLocale()
          Returns the output locale.
 int getRemaining()
           
 boolean hasError()
          Returns true if we're processing an error.
 boolean isCommitted()
          Returns true if some data has been sent to the browser.
 void killCache()
          Set if the page is non-cacheable.
 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 i)
          Sends an HTTP error page based on the status code
 void sendError(int i, java.lang.String message)
          Sends an HTTP error to the browser.
 void sendRedirect(java.lang.String location)
          Sends a redirect to the browser.
 void setBufferSize(int size)
          Sets the output buffer size to size.
 void setContentLength(int length)
          Sets the content length of the result.
 void setContentType(java.lang.String type)
          Sets the browser content type.
 void setDateHeader(java.lang.String header, long value)
          Convenience for setting a date header.
 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 header, java.lang.String value)
          Sets a header, replacing an already-existing header.
 void setIntHeader(java.lang.String header, int value)
          Convenience for setting an integer header.
 void setLocale(java.util.Locale locale)
          Sets the output locale.
 void setPrivateCache(boolean isPrivate)
          Sets true if the cache is only for the browser, but not Resin's cache or proxies.
 void setSessionId(java.lang.String id)
           
 void setStatus(int status)
          Sets the HTTP status
 void setStatus(int status, java.lang.String messages)
           
 boolean writeHeadersInt(WriteStream out, int length, boolean isHead)
           
 
Methods inherited from class com.caucho.server.connection.AbstractHttpResponse
addFooter, createResponseStream, disable, disableCaching, enable, fillCookie, finish, flushHeader, free, getCalendar, getContentLength, getContentLengthHeader, getContentType, getController, getCookie, getCookies, getFlushBuffer, getNextWriter, getOriginalRequest, getOriginalStream, getOutputStream, getPrivateCache, getRawOutput, getRequest, getResponse, getResponseStream, getStatusCode, getStatusMessage, getWriter, init, init, isCacheHit, isCauchoResponseStream, isClosed, isDisabled, isHead, isHeaderWritten, isIgnoreClientDisconnect, isNoCache, isPrivateCache, isTop, killCaching, removeHeader, setCacheHit, setCacheInvocation, setCharacterEncoding, setDisableAutoFlush, setFlushBuffer, setFooter, setHeaderWritten, setMatchCacheEntry, setNoCache, setPrivateOrResinCache, setRequest, setResponseStream, setSpecial, setTopCache, start, startCaching, switchToRaw, upgradeProtocol, writeContinueInt, writeHeaders
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StubServletResponse

public StubServletResponse()
Method Detail

getCharacterEncoding

public java.lang.String getCharacterEncoding()
Description copied from class: AbstractHttpResponse
Gets the character encoding.

Specified by:
getCharacterEncoding in interface ServletResponse
Overrides:
getCharacterEncoding in class AbstractHttpResponse

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
Overrides:
setLocale in class AbstractHttpResponse

getLocale

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

Specified by:
getLocale in interface ServletResponse
Overrides:
getLocale in class AbstractHttpResponse

writeHeadersInt

public boolean writeHeadersInt(WriteStream out,
                               int length,
                               boolean isHead)
Specified by:
writeHeadersInt in class AbstractHttpResponse

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
Overrides:
setBufferSize in class AbstractHttpResponse
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
Overrides:
getBufferSize in class AbstractHttpResponse

flushBuffer

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

Specified by:
flushBuffer in interface ServletResponse
Overrides:
flushBuffer in class AbstractHttpResponse

isCommitted

public boolean isCommitted()
Description copied from class: AbstractHttpResponse
Returns true if some data has been sent to the browser.

Specified by:
isCommitted in interface ServletResponse
Overrides:
isCommitted in class AbstractHttpResponse

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
Overrides:
reset in class AbstractHttpResponse

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
Overrides:
resetBuffer in class AbstractHttpResponse

setContentLength

public void setContentLength(int length)
Description copied from class: AbstractHttpResponse
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
Overrides:
setContentLength in class AbstractHttpResponse
Parameters:
length - the length of the content.

setContentType

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

setStatus

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

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

setStatus

public void setStatus(int status,
                      java.lang.String messages)
Specified by:
setStatus in interface HttpServletResponse
Overrides:
setStatus in class AbstractHttpResponse

sendRedirect

public void sendRedirect(java.lang.String location)
Description copied from class: AbstractHttpResponse
Sends a redirect to the browser. If the URL is relative, it gets combined with the current url.

Specified by:
sendRedirect in interface HttpServletResponse
Overrides:
sendRedirect in class AbstractHttpResponse
Parameters:
location - the possibly relative url to send to the browser

sendError

public void sendError(int i)
Description copied from interface: HttpServletResponse
Sends an HTTP error page based on the status code

Specified by:
sendError in interface HttpServletResponse
Overrides:
sendError in class AbstractHttpResponse
Parameters:
i - the HTTP status code

sendError

public void sendError(int i,
                      java.lang.String message)
Description copied from class: AbstractHttpResponse
Sends an HTTP error to the browser.

Specified by:
sendError in interface HttpServletResponse
Overrides:
sendError in class AbstractHttpResponse
Parameters:
i - the HTTP error code
message - a string message

encodeUrl

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

encodeURL

public java.lang.String encodeURL(java.lang.String url)
Description copied from class: AbstractHttpResponse
Encode the URL with the session jd.

Specified by:
encodeURL in interface HttpServletResponse
Overrides:
encodeURL in class AbstractHttpResponse
Parameters:
url - the url to be encoded
Returns:
the encoded url

encodeRedirectUrl

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

encodeRedirectURL

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

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

addCookie

public void addCookie(Cookie cookie)
Description copied from class: AbstractHttpResponse
Adds a cookie to the response.

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

containsHeader

public boolean containsHeader(java.lang.String header)
Description copied from class: AbstractHttpResponse
Returns true if the response already contains the named header.

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

setHeader

public void setHeader(java.lang.String header,
                      java.lang.String value)
Description copied from class: AbstractHttpResponse
Sets a header, replacing an already-existing header.

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

setIntHeader

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

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

setDateHeader

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

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

addHeader

public void addHeader(java.lang.String header,
                      java.lang.String value)
Description copied from class: AbstractHttpResponse
Adds a new header. If an old header with that name exists, both headers are output.

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

addIntHeader

public void addIntHeader(java.lang.String header,
                         int value)
Description copied from class: AbstractHttpResponse
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
Overrides:
addIntHeader in class AbstractHttpResponse
Parameters:
header - the header name.
value - an integer to be converted to a string for the header.

addDateHeader

public void addDateHeader(java.lang.String header,
                          long value)
Description copied from class: AbstractHttpResponse
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
Overrides:
addDateHeader in class AbstractHttpResponse
Parameters:
header - the header name.
value - an time in milliseconds to be converted to a date string.

getHeader

public java.lang.String getHeader(java.lang.String key)
Description copied from class: AbstractHttpResponse
Returns the value of an already set output header.

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

clearBuffer

public void clearBuffer()
Overrides:
clearBuffer in class AbstractHttpResponse

close

public void close()
           throws java.io.IOException
Description copied from class: AbstractHttpResponse
Closes the request.

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

disableHeaders

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

getRemaining

public int getRemaining()
Overrides:
getRemaining in class AbstractHttpResponse

setForbidForward

public void setForbidForward(boolean forbid)
Description copied from class: AbstractHttpResponse
When set to true, RequestDispatcher.forward() is disallowed on this stream.

Specified by:
setForbidForward in interface CauchoResponse
Overrides:
setForbidForward in class AbstractHttpResponse

getForbidForward

public boolean getForbidForward()
Description copied from class: AbstractHttpResponse
Returns true if RequestDispatcher.forward() is disallowed on this stream.

Specified by:
getForbidForward in interface CauchoResponse
Overrides:
getForbidForward in class AbstractHttpResponse

setHasError

public void setHasError(boolean hasError)
Description copied from class: AbstractHttpResponse
Set to true while processing an error.

Specified by:
setHasError in interface CauchoResponse
Overrides:
setHasError in class AbstractHttpResponse

hasError

public boolean hasError()
Description copied from class: AbstractHttpResponse
Returns true if we're processing an error.

Specified by:
hasError in interface CauchoResponse
Overrides:
hasError in class AbstractHttpResponse

killCache

public void killCache()
Description copied from class: AbstractHttpResponse
Set if the page is non-cacheable.

Specified by:
killCache in interface CauchoResponse
Overrides:
killCache in class AbstractHttpResponse

setPrivateCache

public void setPrivateCache(boolean isPrivate)
Description copied from class: AbstractHttpResponse
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
Overrides:
setPrivateCache in class AbstractHttpResponse

setSessionId

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