HttpResponse

abstract class HttpResponse : HttpMessage, CoroutineScope

A response for HttpClient, second part of HttpClientCall.

Constructors

Link copied to clipboard
fun HttpResponse()

Functions

Link copied to clipboard
open override fun toString(): String

Properties

Link copied to clipboard
abstract val call: HttpClientCall

The associated HttpClientCall containing both the underlying HttpClientCall.request and HttpClientCall.response.

Link copied to clipboard
abstract val content: ByteReadChannel

Unmodified ByteReadChannel with the raw payload of the response.

Link copied to clipboard
abstract val coroutineContext: CoroutineContext
Link copied to clipboard
abstract val headers: Headers
Link copied to clipboard
abstract val requestTime: GMTDate

GMTDate of the request start.

Link copied to clipboard
abstract val responseTime: GMTDate

GMTDate of the response start.

Link copied to clipboard
abstract val status: HttpStatusCode

The HttpStatusCode returned by the server. It includes both, the HttpStatusCode.description and the HttpStatusCode.value (code).

Link copied to clipboard
abstract val version: HttpProtocolVersion

Inheritors

Link copied to clipboard

Extensions

Link copied to clipboard
inline suspend fun <T> HttpResponse.body(): T

Tries to receive the payload of the response as a specific type T.

suspend fun <T> HttpResponse.body(typeInfo: TypeInfo): T

Tries to receive the payload of the response as a specific type T described in typeInfo.

Link copied to clipboard
suspend fun HttpResponse.bodyAsChannel(): ByteReadChannel
Link copied to clipboard
suspend fun HttpResponse.bodyAsText(fallbackCharset: Charset = Charsets.UTF_8): String

Read the HttpResponse.content as a String. You can pass an optional charset to specify a charset in the case no one is specified as part of the Content-Type response. If no charset specified either as parameter or as part of the response, io.ktor.client.plugins.HttpPlainText settings will be used.

Link copied to clipboard
suspend fun HttpResponse.discardRemaining()

Efficiently discards the remaining bytes of HttpResponse.content.

Link copied to clipboard
suspend fun HttpResponse.readBytes(count: Int): ByteArray

Exactly reads count bytes of the HttpResponse.content.

suspend fun HttpResponse.readBytes(): ByteArray

Reads the whole HttpResponse.content if Content-Length was specified. Otherwise it just reads one byte.

Link copied to clipboard
suspend fun HttpResponse.readText(fallbackCharset: Charset? = null): String

Read the HttpResponse.content as a String. You can pass an optional charset to specify a charset in the case no one is specified as part of the Content-Type response. If no charset specified either as parameter or as part of the response, io.ktor.client.plugins.HttpPlainText settings will be used.

Link copied to clipboard
inline suspend fun <T> HttpResponse.receive(): T

Tries to receive the payload of the response as a specific type T.

Link copied to clipboard
val HttpResponse.request: HttpRequest

HttpRequest associated with this response.