HttpStatement

Represents a prepared HTTP request statement for HttpClient.

The HttpStatement class encapsulates a request configuration without executing it immediately. This statement can be executed on-demand via various methods such as execute, allowing for deferred or multiple executions without creating a new request each time.

Deferred Execution

HttpStatement does not initiate any network activity until an execution method is called. It is safe to execute multiple times, which can be useful in scenarios requiring reusability of the same request configuration.

Example: Streaming data

Constructors

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

Functions

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

Executes the HTTP statement and processes the response through HttpClient.responsePipeline to retrieve an instance of the specified type T.

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

Executes the HTTP statement and processes the response of type T through the provided block.

Link copied to clipboard
suspend fun execute(): HttpResponse

Executes the HTTP statement and returns the full HttpResponse.

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

Executes the HTTP statement and invokes the provided block with the streaming HttpResponse.

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