public class SimpleHttpResponse extends Object implements HttpResponse, AutoAsync<HttpResponse>
| Constructor and Description |
|---|
SimpleHttpResponse(HttpStatus status,
ContentType contentType,
byte[] bytes) |
| Instance Methods | |
|---|---|
HttpStatus |
status()
Response status.
|
Map<String,String> |
headers()
Response headers.
|
List<Cookie> |
cookies()
Response cookies.
|
HttpEntity |
entity()
Response entity; null if none.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitbodyBytes, bodyString, header, httpVersion, statusCodecancel, isCompleted, onCompletion, pollResult, timeoutpublic SimpleHttpResponse(HttpStatus status, ContentType contentType, byte[] bytes)
public HttpStatus status()
HttpResponse"200 OK".status in interface HttpResponsepublic Map<String,String> headers()
HttpResponseThe returned Map is case insensitive for lookup. The caller should treat the Map as read-only.
The following headers should not be included in this Map:
"Content-Type").
Entity metadata should be expressed on the HttpResponse.entity().
"Content-Length" and "Transport-Encoding" headers.
They are handled automatically by underlying libraries.
"Set-Cookie" headers. Cookies are represented in HttpResponse.cookies().
See Headers for common header names.
See HeaderMap for a suitable implementation.
See TokenParams for a certain type of header values.
Note that each header contains a single value. Per spec, multiple headers with the same name is identical in semantics to a single combined header:
Foo: value1 |
Foo: value2 | ====> | Foo: value1, value2, value3
Foo: value3 |
headers in interface HttpResponsepublic List<Cookie> cookies()
HttpResponseThe returned list should be treated as read-only by the caller.
Although response cookies are expressed in "Set-Cookie" headers on the wire,
they cannot be treated as normal headers (due to a historical oversight).
Therefore HttpResponse.headers() cannot contain "Set-Cookie" headers;
and, response cookies must be expressed in HttpResponse.cookies().
cookies in interface HttpResponseHttpResponseImpl.cookies(),
CookieJarpublic HttpEntity entity()
HttpResponseA response must have an entity, except in the following cases, where entity() should return null:
If entity() should return null, but returns non-null, the entity should be ignored.
If the request method is HEAD,
response.entity() should behave as if the request method is GET,
with the exception of the body - the recipient of the response must not read the entity body.
entity in interface HttpResponse