|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.caucho.server.http.DummyResponse
Constructor Summary | |
DummyResponse()
|
Method Summary | |
void |
addCookie(Cookie cookie)
Adds the specified cookie to the response. |
void |
addDateHeader(java.lang.String header,
long value)
Adds a response header with the given name and date-value. |
void |
addHeader(java.lang.String header,
java.lang.String value)
Adds a response header with the given name and value. |
void |
addIntHeader(java.lang.String header,
int value)
Adds a response header with the given name and integer value. |
void |
clearBuffer()
|
void |
close()
|
boolean |
containsHeader(java.lang.String header)
Returns a boolean indicating whether the named response header has already been set. |
boolean |
disableHeaders(boolean disable)
|
java.lang.String |
encodeRedirectUrl(java.lang.String url)
|
java.lang.String |
encodeRedirectURL(java.lang.String url)
Encodes the specified URL for use in the sendRedirect method or, if encoding is not needed,
returns the URL unchanged. |
java.lang.String |
encodeUrl(java.lang.String url)
|
java.lang.String |
encodeURL(java.lang.String url)
Encodes the specified URL by including the session ID in it, or, if encoding is not needed, returns the URL unchanged. |
void |
flushBuffer()
Forces any content in the buffer to be written to the client. |
int |
getBufferSize()
Returns the actual buffer size used for the response. |
java.lang.String |
getChain()
|
java.lang.String |
getCharacterEncoding()
Returns the name of the charset used for the MIME body sent in this response. |
boolean |
getForbidForward()
|
java.lang.String |
getHeader(java.lang.String key)
|
java.util.Locale |
getLocale()
Returns the locale assigned to the response. |
ServletOutputStream |
getOutputStream()
Returns a ServletOutputStream suitable for writing binary
data in the response. |
int |
getRemaining()
|
WriteStream |
getStream()
|
java.io.PrintWriter |
getWriter()
Returns a PrintWriter object that
can send character text to the client. |
boolean |
hasError()
|
boolean |
isCommitted()
Returns a boolean indicating if the response has been committed. |
void |
killCache()
|
void |
reset()
Clears any data that exists in the buffer as well as the status code and headers. |
void |
resetBuffer()
Clears the content of the underlying buffer in the response without clearing headers or status code. |
void |
sendError(int i)
Sends an error response to the client using the specified status code and clearing the buffer. |
void |
sendError(int i,
java.lang.String message)
Sends an error response to the client using the specified status clearing the buffer. |
void |
sendRedirect(java.lang.String location)
Sends a temporary redirect response to the client using the specified redirect location URL. |
void |
setBufferSize(int size)
Sets the preferred buffer size for the body of the response. |
void |
setContentLength(int length)
Sets the length of the content body in the response In HTTP servlets, this method sets the HTTP Content-Length header. |
void |
setContentType(java.lang.String type)
Sets the content type of the response being sent to the client. |
void |
setDateHeader(java.lang.String header,
long value)
Sets a response header with the given name and date-value. |
void |
setForbidForward(boolean forbid)
|
void |
setHasError(boolean hasError)
|
void |
setHeader(java.lang.String header,
java.lang.String value)
Sets a response header with the given name and value. |
void |
setIntHeader(java.lang.String header,
int value)
Sets a response header with the given name and integer value. |
void |
setLocale(java.util.Locale locale)
Sets the locale of the response, setting the headers (including the Content-Type's charset) as appropriate. |
void |
setSessionId(java.lang.String id)
|
void |
setStatus(int status)
Sets the status code for this response. |
void |
setStatus(int status,
java.lang.String messages)
|
void |
setStream(WriteStream os)
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public DummyResponse()
Method Detail |
public java.lang.String getCharacterEncoding()
ServletResponse
If no charset has been assigned, it is implicitly
set to ISO-8859-1
(Latin-1
).
See RFC 2047 (http://ds.internic.net/rfc/rfc2045.txt) for more information about character encoding and MIME.
getCharacterEncoding
in interface ServletResponse
javax.servlet.ServletResponse
String
specifying the
name of the charset, for
example, ISO-8859-1
public void setLocale(java.util.Locale locale)
ServletResponse
ServletResponse.getWriter()
. By default, the response locale
is the default locale for the server.setLocale
in interface ServletResponse
javax.servlet.ServletResponse
loc
- the locale of the responseServletResponse.getLocale()
public java.util.Locale getLocale()
ServletResponse
getLocale
in interface ServletResponse
javax.servlet.ServletResponse
ServletResponse.setLocale(java.util.Locale)
public ServletOutputStream getOutputStream() throws java.io.IOException
ServletResponse
ServletOutputStream
suitable for writing binary
data in the response. The servlet container does not encode the
binary data.
Calling flush() on the ServletOutputStream commits the response.
Either this method or ServletResponse.getWriter()
may
be called to write the body, not both.
getOutputStream
in interface ServletResponse
javax.servlet.ServletResponse
ServletOutputStream
for writing binary datajava.lang.IllegalStateException
- if the getWriter
method
has been called on this responsejava.io.IOException
- if an input or output exception occurredServletResponse.getWriter()
public java.io.PrintWriter getWriter() throws java.io.IOException
ServletResponse
PrintWriter
object that
can send character text to the client.
The character encoding used is the one specified
in the charset=
property of the
ServletResponse.setContentType(java.lang.String)
method, which must be called
before calling this method for the charset to take effect.
If necessary, the MIME type of the response is modified to reflect the character encoding used.
Calling flush() on the PrintWriter commits the response.
Either this method or ServletResponse.getOutputStream()
may be called
to write the body, not both.
getWriter
in interface ServletResponse
javax.servlet.ServletResponse
PrintWriter
object that
can return character data to the clientjava.io.UnsupportedEncodingException
- if the charset specified in
setContentType
cannot be
usedjava.lang.IllegalStateException
- if the getOutputStream
method has already been called for this
response objectjava.io.IOException
- if an input or output exception occurredServletResponse.getOutputStream()
,
ServletResponse.setContentType(java.lang.String)
public void setBufferSize(int size)
ServletResponse
getBufferSize
.
A larger buffer allows more content to be written before anything is actually sent, thus providing the servlet with more time to set appropriate status codes and headers. A smaller buffer decreases server memory load and allows the client to start receiving data more quickly.
This method must be called before any response body content is
written; if content has been written, this method throws an
IllegalStateException
.
setBufferSize
in interface CauchoResponse
javax.servlet.ServletResponse
size
- the preferred buffer sizejava.lang.IllegalStateException
- if this method is called after
content has been writtenServletResponse.getBufferSize()
,
ServletResponse.flushBuffer()
,
ServletResponse.isCommitted()
,
ServletResponse.reset()
public int getBufferSize()
ServletResponse
getBufferSize
in interface CauchoResponse
javax.servlet.ServletResponse
ServletResponse.setBufferSize(int)
,
ServletResponse.flushBuffer()
,
ServletResponse.isCommitted()
,
ServletResponse.reset()
public void flushBuffer()
ServletResponse
flushBuffer
in interface CauchoResponse
javax.servlet.ServletResponse
ServletResponse.setBufferSize(int)
,
ServletResponse.getBufferSize()
,
ServletResponse.isCommitted()
,
ServletResponse.reset()
public boolean isCommitted()
ServletResponse
isCommitted
in interface ServletResponse
javax.servlet.ServletResponse
ServletResponse.setBufferSize(int)
,
ServletResponse.getBufferSize()
,
ServletResponse.flushBuffer()
,
ServletResponse.reset()
public void reset()
ServletResponse
IllegalStateException
.reset
in interface CauchoResponse
javax.servlet.ServletResponse
java.lang.IllegalStateException
- if the response has already been
committedServletResponse.setBufferSize(int)
,
ServletResponse.getBufferSize()
,
ServletResponse.flushBuffer()
,
ServletResponse.isCommitted()
public void resetBuffer()
ServletResponse
IllegalStateException
.resetBuffer
in interface ServletResponse
javax.servlet.ServletResponse
ServletResponse.setBufferSize(int)
,
ServletResponse.getBufferSize()
,
ServletResponse.isCommitted()
,
ServletResponse.reset()
public void setContentLength(int length)
ServletResponse
setContentLength
in interface ServletResponse
javax.servlet.ServletResponse
len
- an integer specifying the length of the
content being returned to the client; sets
the Content-Length headerpublic void setContentType(java.lang.String type)
ServletResponse
text/html; charset=ISO-8859-4
.
If obtaining a PrintWriter
, this method should be
called first.
setContentType
in interface ServletResponse
javax.servlet.ServletResponse
type
- a String
specifying the MIME
type of the contentServletResponse.getOutputStream()
,
ServletResponse.getWriter()
public void setStatus(int status)
HttpServletResponse
sendError
method should be used
instead.
The container clears the buffer and sets the Location header, preserving cookies and other headers.
setStatus
in interface HttpServletResponse
javax.servlet.http.HttpServletResponse
sc
- the status codeHttpServletResponse.sendError(int, java.lang.String)
public void setStatus(int status, java.lang.String messages)
setStatus
in interface HttpServletResponse
javax.servlet.http.HttpServletResponse
sc
- the status codesm
- the status messagepublic void sendRedirect(java.lang.String location)
HttpServletResponse
If the response has already been committed, this method throws an IllegalStateException. After using this method, the response should be considered to be committed and should not be written to.
sendRedirect
in interface HttpServletResponse
javax.servlet.http.HttpServletResponse
location
- the redirect location URLjava.io.IOException
- If an input or output exception occursjava.lang.IllegalStateException
- If the response was committedpublic void sendError(int i)
HttpServletResponse
If the response has already been committed, this method throws an IllegalStateException. After using this method, the response should be considered to be committed and should not be written to.
sendError
in interface HttpServletResponse
javax.servlet.http.HttpServletResponse
sc
- the error status codejava.io.IOException
- If an input or output exception occursjava.lang.IllegalStateException
- If the response was committed
before this method callpublic void sendError(int i, java.lang.String message)
HttpServletResponse
If the response has already been committed, this method throws an IllegalStateException. After using this method, the response should be considered to be committed and should not be written to.
sendError
in interface HttpServletResponse
javax.servlet.http.HttpServletResponse
sc
- the error status codemsg
- the descriptive messagejava.io.IOException
- If an input or output exception occursjava.lang.IllegalStateException
- If the response was committedpublic java.lang.String encodeUrl(java.lang.String url)
encodeUrl
in interface HttpServletResponse
javax.servlet.http.HttpServletResponse
url
- the url to be encoded.public java.lang.String encodeURL(java.lang.String url)
HttpServletResponse
For robust session tracking, all URLs emitted by a servlet should be run through this method. Otherwise, URL rewriting cannot be used with browsers which do not support cookies.
encodeURL
in interface HttpServletResponse
javax.servlet.http.HttpServletResponse
url
- the url to be encoded.public java.lang.String encodeRedirectUrl(java.lang.String url)
encodeRedirectUrl
in interface HttpServletResponse
javax.servlet.http.HttpServletResponse
url
- the url to be encoded.public java.lang.String encodeRedirectURL(java.lang.String url)
HttpServletResponse
sendRedirect
method or, if encoding is not needed,
returns the URL unchanged. The implementation of this method
includes the logic to determine whether the session ID
needs to be encoded in the URL. Because the rules for making
this determination can differ from those used to decide whether to
encode a normal link, this method is seperate from the
encodeURL
method.
All URLs sent to the HttpServletResponse.sendRedirect
method should be run through this method. Otherwise, URL
rewriting cannot be used with browsers which do not support
cookies.
encodeRedirectURL
in interface HttpServletResponse
javax.servlet.http.HttpServletResponse
url
- the url to be encoded.HttpServletResponse.sendRedirect(java.lang.String)
,
HttpServletResponse.encodeUrl(java.lang.String)
public void addCookie(Cookie cookie)
HttpServletResponse
addCookie
in interface HttpServletResponse
javax.servlet.http.HttpServletResponse
cookie
- the Cookie to return to the clientpublic boolean containsHeader(java.lang.String header)
HttpServletResponse
containsHeader
in interface HttpServletResponse
javax.servlet.http.HttpServletResponse
name
- the header nametrue
if the named response header
has already been set;
false
otherwisepublic void setHeader(java.lang.String header, java.lang.String value)
HttpServletResponse
containsHeader
method can be
used to test for the presence of a header before setting its
value.setHeader
in interface HttpServletResponse
javax.servlet.http.HttpServletResponse
name
- the name of the headervalue
- the header valueHttpServletResponse.containsHeader(java.lang.String)
,
HttpServletResponse.addHeader(java.lang.String, java.lang.String)
public void setIntHeader(java.lang.String header, int value)
HttpServletResponse
containsHeader
method can be used to test for the presence of a header before
setting its value.setIntHeader
in interface HttpServletResponse
javax.servlet.http.HttpServletResponse
name
- the name of the headervalue
- the assigned integer valueHttpServletResponse.containsHeader(java.lang.String)
,
HttpServletResponse.addIntHeader(java.lang.String, int)
public void setDateHeader(java.lang.String header, long value)
HttpServletResponse
containsHeader
method can be used to test for the
presence of a header before setting its value.setDateHeader
in interface HttpServletResponse
javax.servlet.http.HttpServletResponse
name
- the name of the header to setvalue
- the assigned date valueHttpServletResponse.containsHeader(java.lang.String)
,
HttpServletResponse.addDateHeader(java.lang.String, long)
public void addHeader(java.lang.String header, java.lang.String value)
HttpServletResponse
addHeader
in interface CauchoResponse
javax.servlet.http.HttpServletResponse
name
- the name of the headervalue
- the additional header valueHttpServletResponse.setHeader(java.lang.String, java.lang.String)
public void addIntHeader(java.lang.String header, int value)
HttpServletResponse
addIntHeader
in interface HttpServletResponse
javax.servlet.http.HttpServletResponse
name
- the name of the headervalue
- the assigned integer valueHttpServletResponse.setIntHeader(java.lang.String, int)
public void addDateHeader(java.lang.String header, long value)
HttpServletResponse
addDateHeader
in interface HttpServletResponse
javax.servlet.http.HttpServletResponse
name
- the name of the header to setvalue
- the additional date valueHttpServletResponse.setDateHeader(java.lang.String, long)
public WriteStream getStream() throws java.io.IOException
getStream
in interface CauchoResponse
public void setStream(WriteStream os)
setStream
in interface CauchoResponse
public java.lang.String getChain() throws java.io.IOException
getChain
in interface CauchoResponse
public java.lang.String getHeader(java.lang.String key)
getHeader
in interface CauchoResponse
public void clearBuffer()
clearBuffer
in interface CauchoResponse
public void close() throws java.io.IOException
close
in interface CauchoResponse
public boolean disableHeaders(boolean disable)
disableHeaders
in interface CauchoResponse
public int getRemaining()
getRemaining
in interface CauchoResponse
public void setForbidForward(boolean forbid)
setForbidForward
in interface CauchoResponse
public boolean getForbidForward()
getForbidForward
in interface CauchoResponse
public void setHasError(boolean hasError)
setHasError
in interface CauchoResponse
public boolean hasError()
hasError
in interface CauchoResponse
public void killCache()
killCache
in interface CauchoResponse
public void setSessionId(java.lang.String id)
setSessionId
in interface CauchoResponse
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |