类 Response
- java.lang.Object
-
- io.itit.itf.okhttp.Response
-
public class Response extends Object
- 作者:
- skydu
-
-
构造器概要
构造器 构造器 说明 Response(okhttp3.Response response)
-
方法概要
所有方法 实例方法 具体方法 修饰符和类型 方法 说明 okhttp3.ResponseBodybody()Nevernull, must be closed after consumption, can be consumed only once.byte[]bytes()InputStreambyteStream()intcode()okhttp3.ResponsegetResponse()okhttp3.Handshakehandshake()Returns the TLS handshake of the connection that carried this response, or null if the response was received without TLS.Stringheader(String name)Stringheader(String name, String defaultValue)okhttp3.Headersheaders()List<String>headers(String name)booleanisSuccessful()Stringmessage()okhttp3.ResponseBodypeekBody(long byteCount)Peeks up tobyteCountbytes from the response body and returns them as a new response body.okhttp3.Protocolprotocol()okhttp3.Requestrequest()Stringstring()Returns the response as a string decoded with the charset of the Content-Type header.Stringstring(String charset)Returns the response as a string decoded with the charset of the Content-Type header.
-
-
-
方法详细资料
-
request
public okhttp3.Request request()
- 返回:
-
protocol
public okhttp3.Protocol protocol()
- 返回:
-
code
public int code()
- 返回:
-
isSuccessful
public boolean isSuccessful()
- 返回:
-
message
public String message()
- 返回:
-
handshake
public okhttp3.Handshake handshake()
Returns the TLS handshake of the connection that carried this response, or null if the response was received without TLS.
-
headers
public okhttp3.Headers headers()
-
peekBody
public okhttp3.ResponseBody peekBody(long byteCount) throws IOExceptionPeeks up tobyteCountbytes from the response body and returns them as a new response body. If fewer thanbyteCountbytes are in the response body, the full response body is returned. If more thanbyteCountbytes are in the response body, the returned value will be truncated tobyteCountbytes.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
-
body
public okhttp3.ResponseBody body()
Nevernull, must be closed after consumption, can be consumed only once.
-
string
public final String string() throws IOException
Returns the response as a string decoded with the charset of the Content-Type header. If that header is either absent or lacks a charset, this will attempt to decode the response body as UTF-8.- 抛出:
IOException
-
string
public final String string(String charset) throws IOException
Returns the response as a string decoded with the charset of the Content-Type header. If that header is either absent or lacks a charset, this will attempt to decode the response body as UTF-8.- 抛出:
IOException
-
bytes
public final byte[] bytes() throws IOException- 抛出:
IOException
-
byteStream
public final InputStream byteStream()
-
getResponse
public okhttp3.Response getResponse()
-
-