body
Executes the HTTP statement and processes the response through HttpClient.responsePipeline to retrieve an instance of the specified type T.
If T represents a streaming type (such as ByteReadChannel), it is the caller's responsibility to properly manage the resource, ensuring it is closed when no longer needed.
Return
The response body transformed to the specified type T.
Executes the HTTP statement and processes the response of type T through the provided block.
This function is particularly useful for handling streaming responses, allowing you to process data on-the-fly while the network connection remains open. The block receives the streamed response and can be used to perform operations on the data as it arrives.
Once block completes, the resources associated with the response are automatically cleaned up, freeing any network or memory resources held by the response.
Usage Example
client.request {
url("https://ktor.io")
}.body<ByteReadChannel> { channel ->
// Process streaming data here
}
// Resources are released automatically after block completes
Return
The result of block applied to the streaming response.
Parameters
A suspend function that handles the streamed response of type T.