ktor-client-core / io.ktor.client.statement / HttpStatement

HttpStatement

class HttpStatement

Prepared statement for http client request. This statement doesn't perform any network requests until execute method call.

HttpStatement is safe to execute multiple times.

Constructors

<init>

HttpStatement(builder: HttpRequestBuilder, client: HttpClient)

Prepared statement for http client request. This statement doesn't perform any network requests until execute method call.

Functions

body

suspend fun <T> body(): T

Executes this statement and run HttpClient.responsePipeline with the response and expected type T.

suspend fun <T, R> body(block: suspend (response: T) -> R): R

Executes this statement and run the block with a HttpClient.responsePipeline execution result.

execute

suspend fun <T> execute(block: suspend (response: HttpResponse) -> T): T

Executes this statement and call the block with the streaming response.

suspend fun execute(): HttpResponse

Executes this statement and download the response. After the method finishes, the client downloads the response body in memory and release the connection.

toString

fun toString(): String

Extension Functions

receive

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

Executes this statement and run HttpClient.responsePipeline with the response and expected type T.

suspend fun <T, R> HttpStatement.receive(block: suspend (response: T) -> R): R

Executes this statement and run the block with a HttpClient.responsePipeline execution result.