类 Response


  • public class Response
    extends Object
    作者:
    skydu
    • 构造器详细资料

      • Response

        public Response​(okhttp3.Response response)
        参数:
        response -
    • 方法详细资料

      • 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 IOException
        Peeks up to 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
      • body

        public okhttp3.ResponseBody body()
        Never null, 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
      • getResponse

        public okhttp3.Response getResponse()