Client
In addition to HTTP serving, Ktor also includes a flexible asynchronous HTTP client. This client supports several , and has its own set of features.
The main functionality is available through the artifact. And each engine, is provided in .
You can check how to make requests, and 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 examples page with some examples.
For more information, check the with all the available features.