public interface HttpResponse extends StatusCode, HttpHeaders
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_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_TEMPORARY_REDIRECT, SC_UNAUTHORIZED, SC_UNSUPPORTED_MEDIA_TYPE, SC_USE_PROXYACCEPT, ACCEPT_CHARSET, ACCEPT_ENCODING, ACCEPT_LANGUAGE, ACCEPT_RANGES, Access_Control_Allow_Credentials, Access_Control_Allow_Headers, Access_Control_Allow_Methods, Access_Control_Allow_Origin, Access_Control_Expose_Headers, Access_Control_Max_Age, Access_Control_Request_Headers, Access_Control_Request_Method, AGE, ALLOW, AUTHORIZATION, CACHE_CONTROL, CONNECTION, CONTENT_ENCODING, CONTENT_LANGUAGE, CONTENT_LENGTH, CONTENT_LOCATION, CONTENT_MD5, CONTENT_RANGE, CONTENT_TYPE, COOKIE, DATE, DAV, DEPTH, DESTINATION, ETAG, EXPECT, EXPIRES, FROM, HOST, IF, IF_MATCH, IF_MODIFIED_SINCE, IF_NONE_MATCH, IF_RANGE, IF_UNMODIFIED_SINCE, LAST_MODIFIED, LOCATION, LOCK_TOKEN, MAX_FORWARDS, ORIGIN, OVERWRITE, PRAGMA, PROXY_AUTHENTICATE, PROXY_AUTHORIZATION, RANGE, REFERER, RETRY_AFTER, SERVER, SET_COOKIE, STATUS_URI, TE, TIMEOUT, TRAILER, TRANSFER_ENCODING, UPGRADE, USER_AGENT, VARY, VIA, WARNING, WWW_AUTHENTICATE| Modifier and Type | Method and Description |
|---|---|
void |
addCookie(Cookie cookie)
Adds the specified cookie to the response.
|
void |
addDateHeader(java.lang.String name,
long date)
Adds a response header with the given name and date-value.
|
void |
addHeader(java.lang.String name,
java.lang.String value)
Adds a response header with the given name and value.
|
void |
addIntHeader(java.lang.String name,
int value)
Adds a response header with the given name and integer value.
|
boolean |
containsHeader(java.lang.String name)
Returns a boolean indicating whether the named response header has already been set.
|
java.lang.String |
getHeader(java.lang.String name)
Gets the value of the response header with the given name.
|
java.util.List<java.lang.String> |
getHeaderNames()
Gets the names of the headers of this response.
|
java.util.List<java.lang.String> |
getHeaders(java.lang.String name)
Gets the values of the response header with the given name.
|
int |
getStatus()
Gets the current status code of this response.
|
void |
sendRedirect(java.lang.String location)
Sends a temporary redirect response to the client using the specified redirect location URL and clears the buffer.
|
void |
setBody(ResponseBody body)
Set the response body.
|
void |
setDateHeader(java.lang.String name,
long date)
Sets a response header with the given name and date-value.
|
void |
setHeader(java.lang.String name,
java.lang.String value)
Sets a response header with the given name and value.
|
void |
setIntHeader(java.lang.String name,
int value)
Sets a response header with the given name and integer value.
|
void |
setStatus(int sc)
Sets the status code for this response.
|
void setStatus(int sc)
This method preserves any cookies and other response headers.
Valid status codes are those in the 2XX, 3XX, 4XX, and 5XX ranges. Other status codes will be considered to be specific.
int getStatus()
void setHeader(java.lang.String name,
java.lang.String value)
containsHeader(String) method can be used to test for the presence of a header before
setting its value.containsHeader(String),
addHeader(String, String)void addHeader(java.lang.String name,
java.lang.String value)
setHeader(String, String)java.lang.String getHeader(java.lang.String name)
If a response header with the given name exists and contains multiple values, the value that was added first will be returned.
name - the name of the response header.null if no header with the given name has
been set on this response.void setDateHeader(java.lang.String name,
long date)
If the header had already been set, the new value overwrites the previous one. The containsHeader(String) method can be used to test for the presence of a header before setting its value.
void addDateHeader(java.lang.String name,
long date)
setDateHeader(String, long)void setIntHeader(java.lang.String name,
int value)
containsHeader(String) method can be used to test for the presence of a
header before setting its value.containsHeader(String),
addIntHeader(String, int)void addIntHeader(java.lang.String name,
int value)
setIntHeader(String, int)boolean containsHeader(java.lang.String name)
java.util.List<java.lang.String> getHeaders(java.lang.String name)
name - the name of the response header.List of the values of the response header with the given name.java.util.List<java.lang.String> getHeaderNames()
Enumeration of the names of the headers of this response.void addCookie(Cookie cookie)
cookie - the cookie to return to the client.void sendRedirect(java.lang.String location)
StatusCode.SC_FOUND.void setBody(ResponseBody body)
body - write the message content sent to the client.