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.

  1. suspend fun parallelRequests() = coroutineScope<Unit> {
  2. val client = HttpClient()
  3. // Start two requests asynchronously.
  4. val firstRequest = async { client.get<ByteArray>("https://127.0.0.1:8080/a") }
  5. // requests are done.
  6. val bytes1 = firstRequest.await() // Suspension point.
  7. val bytes2 = secondRequest.await() // Suspension point.
  8. }

For more information, check the with some examples.

For more information, check the features page with all the available features.