retrofit / retrofit2 / Response

Response

class Response<T : Any!>

An HTTP response.

Functions

body

fun body(): T?

The deserialized response body of a successful response.

code

fun code(): Int

HTTP status code.

error

static fun <T : Any!> error(code: Int, body: ResponseBody!): Response<T>!

Create a synthetic error response with an HTTP status code of code and body as the error body.

static fun <T : Any!> error(body: ResponseBody!, rawResponse: Response!): Response<T>!

Create an error response from rawResponse with body as the error body.

errorBody

fun errorBody(): ResponseBody?

The raw response body of an unsuccessful response.

headers

fun headers(): Headers!

HTTP headers.

isSuccessful

fun isSuccessful(): Boolean

Returns true if #code() is in the range [200..300).

message

fun message(): String!

HTTP status message or null if unknown.

raw

fun raw(): Response!

The raw response from the HTTP client.

success

static fun <T : Any!> success(body: T?): Response<T>!

Create a synthetic successful response with body as the deserialized body.

static fun <T : Any!> success(code: Int, body: T?): Response<T>!

Create a synthetic successful response with an HTTP status code of code and body as the deserialized body.

static fun <T : Any!> success(body: T?, headers: Headers!): Response<T>!

Create a synthetic successful response using headers with body as the deserialized body.

static fun <T : Any!> success(body: T?, rawResponse: Response!): Response<T>!

Create a successful response from rawResponse with body as the deserialized body.

toString

fun toString(): String