Client
In addition to HTTP serving, Ktor also includes a flexible asynchronous HTTP client. This client supports several configurable engines, and has its own set of .
The main functionality is available through the artifact. And each engine, is provided in separate artifacts.
You can check , and how to receive responses in their respective sections.
suspend fun parallelRequests() = coroutineScope<Unit> {
val client = HttpClient()
// Start two requests asynchronously.
val firstRequest = async { client.get<ByteArray>("https://127.0.0.1:8080/a") }
// requests are done.
val bytes1 = firstRequest.await() // Suspension point.
val bytes2 = secondRequest.await() // Suspension point.
}
For more information, check the with some examples.
For more information, check the features page with all the available features.