Response

open class Response : Closeable

Response obtained by calling Request.execute()

Constructors

Link copied to clipboard
constructor(req: Http.Request)
Construct a Response

Functions

Link copied to clipboard
open fun assertOk()
Throws an HttpException if this request was unsuccessful
Link copied to clipboard
open fun close()
Closes the Request associated with this Response
Link copied to clipboard
open fun getBytes(): Array<Byte>
Get the response body as byte[]
Link copied to clipboard
open fun <T> json(type: Class<T>): T
open fun <T> json(type: Type): T
open fun <T> json(gson: Gson, type: Class<T>): T
open fun <T> json(gson: Gson, type: Type): T
Deserializes json response
Link copied to clipboard
open fun ok(): Boolean
Whether the request was successful (status code 2xx)
Link copied to clipboard
open fun pipe(os: OutputStream)
Pipe response into OutputStream.
Link copied to clipboard
open fun saveToFile(@NonNull file: File)
Saves the received data to the specified File
open fun saveToFile(@NonNull file: File, @Nullable sha1sum: String)
Saves the received data to the specified File and verifies its integrity using the specified sha1sum
Link copied to clipboard
open fun stream(): InputStream
Get the raw response stream of this connection
Link copied to clipboard
open fun text(): String
Get the response body as String

Properties

Link copied to clipboard
The status code of this response
Link copied to clipboard
The status message of this response