ktor-client-core / io.ktor.client.call / HttpClientCall

HttpClientCall

open class HttpClientCall : CoroutineScope

A class that represents a single pair of request and response for a specific HttpClient.

Properties

allowDoubleReceive

open val allowDoubleReceive: Boolean

attributes

val attributes: Attributes

Typed Attributes associated to this call serving as a lightweight container.

client

val client: HttpClient?

: client that executed the call.

coroutineContext

open val coroutineContext: <ERROR CLASS>

request

lateinit var request: HttpRequest

Represents the request sent by the client

response

lateinit var response: HttpResponse

Represents the response sent by the server.

Functions

body

suspend fun body(info: TypeInfo): Any

Tries to receive the payload of the response as a specific expected type provided in info. Returns response if info corresponds to HttpResponse.

getResponseContent

open suspend fun getResponseContent(): ByteReadChannel

toString

open fun toString(): String

Companion Object Properties

CustomResponse

val CustomResponse: AttributeKey<Any>

CustomResponse key used to process the response of custom type in case of HttpClientEngine can't return body bytes directly. If present, attribute value will be an initial value for HttpResponseContainer in HttpClient.responsePipeline.

Extension Functions

body

suspend fun <T> HttpClientCall.body(): T

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

mapEngineExceptions

fun CoroutineScope.mapEngineExceptions(input: ByteReadChannel, request: HttpRequestData): ByteReadChannel

Returns ByteReadChannel with ByteChannel.close handler that returns SocketTimeoutException instead of SocketTimeoutException.

fun CoroutineScope.mapEngineExceptions(output: ByteWriteChannel, request: HttpRequestData): ByteWriteChannel

Returns ByteWriteChannel with ByteChannel.close handler that returns SocketTimeoutException instead of SocketTimeoutException.

receive

suspend fun <T> HttpClientCall.receive(): T

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

save

suspend fun HttpClientCall.save(): HttpClientCall

Fetch data for HttpClientCall and close the origin.

wrapWithContent

fun HttpClientCall.wrapWithContent(content: ByteReadChannel, shouldCloseOrigin: Boolean): HttpClientCall
fun HttpClientCall.wrapWithContent(content: ByteReadChannel): HttpClientCall

Wrap existing HttpClientCall with new content.