https://kotlinlang.org logo
#ktor
Title
# ktor
d

davidasync

06/26/2019, 10:45 AM
Hello sorry for noob question
Copy code
suspend fun main () = coroutineScope {
    var counter = 1
    val client = HttpClient{}

    val response = client.get<HttpResponse>("<https://httpbin.org/get>")

    println(response.status)
}
If I defined the HttpClient like that code, is it mean I use CIO engine ?
✔️ 1
e

e5l

06/26/2019, 12:50 PM
Hi @davidasync, no. It means that you’re using the engine mentioned in the
dependencies
block of your build configuration.
d

davidasync

06/26/2019, 1:07 PM
What if I defined more than 1 engine at build.gradle? for example
Copy code
compile "io.ktor:ktor-client-core:latest.release"
    compile "io.ktor:ktor-client-apache:latest.release"
    compile "io.ktor:ktor-client-jetty:latest.release"
    compile "io.ktor:ktor-client-okhttp:latest.release"
    compile "io.ktor:ktor-client-cio:latest.release"
e

e5l

06/26/2019, 1:08 PM
It selects the first one in alphabetical order.
d

davidasync

06/26/2019, 1:13 PM
Ahh I see, Thanks for the explanation
3 Views