Package com.squareup.okhttp
Class Response
java.lang.Object
com.squareup.okhttp.Response
public final class Response extends Object
An HTTP response. Instances of this class are not immutable: the response
body is a one-shot value that may be consumed only once. All other properties
are immutable.
Warning: Experimental OkHttp 2.0 API
This class is in beta. APIs are subject to change!-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classResponse.Bodystatic classResponse.Builderstatic interfaceResponse.Receiver -
Method Summary
Modifier and Type Method Description Response.Bodybody()intcode()Stringheader(String name)Stringheader(String name, String defaultValue)intheaderCount()StringheaderName(int index)Set<String>headerNames()List<String>headers(String name)StringheaderValue(int index)ResponseredirectedBy()Returns the response for the HTTP redirect that triggered this response, or null if this response wasn't triggered by an automatic redirect.Requestrequest()The wire-level request that initiated this HTTP response.
-
Method Details
-
request
The wire-level request that initiated this HTTP response. This is usually not the same request instance provided to the HTTP client:- It may be transformed by the HTTP client. For example, the client
may have added its own
Content-Encodingheader to enable response compression. - It may be the request generated in response to an HTTP redirect. In this case the request URL may be different than the initial request URL.
- It may be transformed by the HTTP client. For example, the client
may have added its own
-
code
public int code() -
header
-
header
-
headers
-
headerNames
-
headerCount
public int headerCount() -
headerName
-
headerValue
-
body
-
redirectedBy
Returns the response for the HTTP redirect that triggered this response, or null if this response wasn't triggered by an automatic redirect. The body of the returned response should not be read because it has already been consumed by the redirecting client.
-