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, wait
bodyBytes, bodyString, header, httpVersion, statusCode
cancel, isCompleted, onCompletion, pollResult, timeout
public SimpleHttpResponse(HttpStatus status, ContentType contentType, byte[] bytes)
public HttpStatus status()
HttpResponse
"200 OK"
.status
in interface HttpResponse
public Map<String,String> headers()
HttpResponse
The 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 HttpResponse
public List<Cookie> cookies()
HttpResponse
The 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 HttpResponse
HttpResponseImpl.cookies()
,
CookieJar
public HttpEntity entity()
HttpResponse
A 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