execute

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

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

The response holds an open network connection until block completes. You can access the response body incrementally (streaming) or load it entirely with body().

After block finishes, the response is finalized based on the engine's configuration—either discarded or released. The response object should not be accessed outside of block as it will be canceled upon block completion.

Return

The result of executing block with the streaming response.

Parameters

block

A suspend function that receives the HttpResponse for streaming.


suspend fun execute(): HttpResponse

Executes the HTTP statement and returns the full HttpResponse.

Once the method completes, the response body is downloaded fully into memory, and the connection is released. This is suitable for requests where the entire response body is needed at once.

For retrieving a specific data type directly, consider using body().

Return

HttpResponse The complete response with the body loaded into memory.