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

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.

receive

suspend fun <T> receive(): T

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

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

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

toString

fun toString(): String

Extension Properties

response

Extension Functions

use

fun <T> HttpStatement.use(
    block: suspend (response: HttpResponse) -> T
): Unit