public class Response extends Object
| 构造器 | 说明 |
|---|---|
Response(okhttp3.Response response) |
| 修饰符和类型 | 方法 | 说明 |
|---|---|---|
okhttp3.ResponseBody |
body() |
Never
null, must be closed after consumption, can be consumed
only once. |
byte[] |
bytes() |
|
InputStream |
byteStream() |
|
int |
code() |
|
okhttp3.Response |
getResponse() |
|
okhttp3.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 name) |
|
String |
header(String name,
String defaultValue) |
|
okhttp3.Headers |
headers() |
|
List<String> |
headers(String name) |
|
boolean |
isSuccessful() |
|
String |
message() |
|
okhttp3.ResponseBody |
peekBody(long byteCount) |
Peeks up to
byteCount bytes from the response body and returns
them as a new response body. |
okhttp3.Protocol |
protocol() |
|
okhttp3.Request |
request() |
|
String |
string() |
Returns the response as a string decoded with the charset of the
Content-Type header.
|
String |
string(String charset) |
Returns the response as a string decoded with the charset of the
Content-Type header.
|
public okhttp3.Request request()
public okhttp3.Protocol protocol()
public int code()
public boolean isSuccessful()
public String message()
public okhttp3.Handshake handshake()
public okhttp3.Headers headers()
public okhttp3.ResponseBody peekBody(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.
IOExceptionpublic okhttp3.ResponseBody body()
null, must be closed after consumption, can be consumed
only once.public final String string() throws IOException
IOExceptionpublic final String string(String charset) throws IOException
IOExceptionpublic final byte[] bytes()
throws IOException
IOExceptionpublic final InputStream byteStream()
public okhttp3.Response getResponse()
Copyright © 2019. All rights reserved.