public final class Response extends Object
| Modifier and Type | Class and Description |
|---|---|
static class |
Response
|
| Modifier and Type | Method and Description |
|---|---|
ResponseBody |
body()
|
CacheControl |
cacheControl()
Returns the cache control directives for this response.
|
Response |
cacheResponse()
Returns the raw response received from the cache.
|
List |
challenges()
Returns the authorization challenges appropriate for this response's code.
|
int |
code()
Returns the HTTP status code.
|
Handshake |
handshake()
Returns the TLS handshake of the connection that carried this response, or null if the response was received without TLS.
|
String |
header(String
|
String |
header(String
|
Headers |
headers()
|
List |
headers(String
|
boolean |
isRedirect()
Returns true if this response redirects to another resource.
|
boolean |
isSuccessful()
Returns true if the code is in [200..300), which means the request was successfully received, understood, and accepted.
|
String |
message()
Returns the HTTP status message or null if it is unknown.
|
Response |
networkResponse()
Returns the raw response received from the network.
|
Response |
newBuilder()
|
ResponseBody |
peekBody(long byteCount)
Peeks up to
byteCount bytes from the response body and returns them as a new response body.
|
Response |
priorResponse()
Returns the response for the HTTP redirect or authorization challenge that triggered this response, or null if this response wasn't triggered by an automatic retry.
|
Protocol |
protocol()
Returns the HTTP protocol, such as
Protocol or
Protocol.
|
Request |
request()
The wire-level request that initiated this HTTP response.
|
String |
toString()
|
public Requestrequest()
Content-Length from the request body. public Protocolprotocol()
Protocol.HTTP_1_1 or
Protocol.HTTP_1_0 .
public int code()
public boolean isSuccessful()
public Stringmessage()
public Handshakehandshake()
public Headersheaders()
public ResponseBodypeekBody(long byteCount) throws IOException
byteCount bytes from the response body and returns them as a new response body. If fewer than
byteCount bytes are in the response body, the full response body is returned. If more than
byteCount bytes are in the response body, the returned value will be truncated to
byteCount bytes.
It is an error to call this method after the body has been consumed.
Warning: this method loads the requested bytes into memory. Most applications should set a modest limit on byteCount, such as 1 MiB.
IOException
public ResponseBodybody()
public Response.Builder newBuilder()
public boolean isRedirect()
public ResponsenetworkResponse()
public ResponsecacheResponse()
public ResponsepriorResponse()
public List<Challenge > challenges()
public CacheControlcacheControl()
Cache-Control header.
public StringtoString()