public interface RsfHttpResponse
| 限定符和类型 | 方法和说明 |
|---|---|
void |
addHeader(String name,
String value)
Adds a response header with the given name and value.
|
boolean |
containsHeader(String name)
Returns a boolean indicating whether the named response header has already been set.
|
void |
flushBuffer()
Forces any content in the buffer to be written to the client.
|
String |
getContentType()
Returns the content type used for the MIME body
sent in this response.
|
String |
getHeader(String name)
Gets the value of the response header with the given name.
|
Collection<String> |
getHeaderNames()
Gets the names of the headers of this response.
|
Collection<String> |
getHeaders(String name)
Gets the values of the response header with the given name.
|
OutputStream |
getOutputStream()
Returns a
OutputStream suitable for writing binary data in the response. |
int |
getStatus()
Gets the current status code of this response.
|
boolean |
isCommitted()
Returns a boolean indicating if the response has been committed.
|
void |
sendError(int sc)
Sends an error response to the client using the specified status
code and clears the buffer.
|
void |
sendError(int sc,
String msg)
Sends an error response to the client using the specified
status and clears the buffer.
|
void |
setContentLength(long len)
Sets the length of the content body in the response
In HTTP servlets, this method sets the HTTP Content-Length header.
|
void |
setContentType(String type)
Sets the content type of the response being sent to
the client, if the response has not been committed yet.
|
void |
setHeader(String name,
String value)
Sets a response header with the given name and value.
|
String getContentType()
setContentType(java.lang.String)
before the response is committed. If no content type
has been specified, this method returns null.
If a content type has been specified, and a
character encoding.
If no character encoding has been specified, the
charset parameter is omitted.String specifying the content type,
for example, text/html; charset=UTF-8, or nullvoid setContentType(String type)
text/html;charset=UTF-8.
The response's character encoding is only set from the given
content type if this method is called before getWriter
is called.
This method may be called repeatedly to change content type and
character encoding.
This method has no effect if called after the response
has been committed. It does not set the response's character
encoding if it is called after getWriter
has been called or after the response has been committed.
Containers must communicate the content type and the character
encoding used for the servlet response's writer to the client if
the protocol provides a way for doing so. In the case of HTTP,
the Content-Type header is used.
type - a String specifying the MIME type of the contentgetOutputStream()OutputStream getOutputStream() throws IOException
OutputStream suitable for writing binary data in the response.
The servlet container does not encode the binary data.OutputStream for writing binary dataIOException - if an input or output exception occurredvoid setContentLength(long len)
len - an integer specifying the length of the
content being returned to the client; sets the Content-Length headervoid flushBuffer()
throws IOException
IOExceptionisCommitted()boolean isCommitted()
void sendError(int sc,
String msg)
throws IOException
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.
sc - the error status codemsg - the descriptive messageIOException - If an input or output exception occursIllegalStateException - If the response was committedvoid sendError(int sc)
throws IOException
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.
sc - the error status codeIOException - If an input or output exception occursIllegalStateException - If the response was committed
before this method callint getStatus()
boolean containsHeader(String name)
name - the header nametrue if the named response header has already been set; false otherwisevoid setHeader(String name, String value)
containsHeader method can be
used to test for the presence of a header before setting its
value.name - the name of the headervalue - the header value If it contains octet string,
it should be encoded according to RFC 2047
(http://www.ietf.org/rfc/rfc2047.txt)containsHeader(java.lang.String),
addHeader(java.lang.String, java.lang.String)void addHeader(String name, String value)
name - the name of the headervalue - the additional header value If it contains
octet string, it should be encoded
according to RFC 2047
(http://www.ietf.org/rfc/rfc2047.txt)setHeader(java.lang.String, java.lang.String)String getHeader(String name)
If a response header with the given name exists and contains multiple values, the value that was added first will be returned.
This method considers only response headers set or added via
setHeader(java.lang.String, java.lang.String), addHeader(java.lang.String, java.lang.String), respectively.
name - the name of the response header whose value to returnCollection<String> getHeaders(String name)
This method considers only response headers set or added via
setHeader(java.lang.String, java.lang.String), addHeader(java.lang.String, java.lang.String), respectively.
Any changes to the returned Collection must not
affect this HttpServletResponse.
name - the name of the response header whose values to returnCollection of the values
of the response header with the given nameCollection<String> getHeaderNames()
This method considers only response headers set or added via
setHeader(java.lang.String, java.lang.String), addHeader(java.lang.String, java.lang.String), respectively.
Any changes to the returned Collection must not
affect this HttpServletResponse.
Collection of the names
of the headers of this responseCopyright © 2020–2021. All rights reserved.