HttpStatement

class HttpStatement(builder: HttpRequestBuilder, client: HttpClient)

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

Link copied to clipboard
fun HttpStatement(builder: HttpRequestBuilder, client: HttpClient)

Functions

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

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

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

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

Link copied to clipboard
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.

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

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

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

Extensions

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

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

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

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