Hi everyone, I'm very new to multiplatform but am ...
# multiplatform
m
Hi everyone, I'm very new to multiplatform but am trying to create a simple HTTP GET request on Linux following this guide. I'm trying to use CIO as my engine on Linux but get the following error when trying to GET https://ktor.io/.
Copy code
Uncaught Kotlin exception: kotlin.IllegalStateException: TLS sessions are not supported on Native platform.
The code at this stage is fairly simple:
Copy code
val client = HttpClient(CIO)

val httpResponse = client.get("<https://ktor.io/>")
val stringBody = httpResponse.body<String>()

println(stringBody)
Here's my `build.gradle.kts`:
Copy code
sourceSets {
    commonMain.dependencies {
      implementation(libs.clikt)
      implementation(libs.kotlinxCoroutines)
      implementation(libs.kotlinxSerializationJson)
      implementation(libs.ktor.client.core)
      implementation(libs.ktor.client.cio)
      implementation(libs.okio)
    }
  }
Am I doing something wrong or is making network requests on Linux not achievable with Kotlin Multiplatform? Thanks in advance.
solved 1
k
Have you tried a different engine aside CIO? try Darwin
Also if you want a String response, you do something like below
Copy code
val stringBody = httpResponse.bodyAsText()
👍 1
m
I'm going to be running (eventually) a command line app from a Github Linux runner. So I assumed that Darwin wasn't the engine I needed. Is my assumption wrong here blob thinking upside down ? But on the point about switching engines I have just tried the Curl engine which worked in the way I wanted. 🎉 Thanks!
🙌 1