Skip to content

Commit 9a2d27c

Browse files
committed
Switch over to OkHttp engine
1 parent bdc505d commit 9a2d27c

File tree

3 files changed

+4
-5
lines changed

3 files changed

+4
-5
lines changed

build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ repositories {
1818
dependencies {
1919
implementation(libs.kotlin.reflect)
2020
implementation(libs.ktor.client.core)
21-
implementation(libs.ktor.client.cio)
21+
implementation(libs.ktor.client.okhttp)
2222
implementation(libs.ktor.serialization.kotlinx.json)
2323
implementation(libs.ktor.client.content.negotiation)
2424
implementation(libs.ktor.logging.plugin)

gradle/libs.versions.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ jacksonKotlin = "2.18.2"
99

1010
[libraries]
1111
ktor-client-core = { module = "io.ktor:ktor-client-core", version.ref = "ktor" }
12-
ktor-client-cio = { module = "io.ktor:ktor-client-cio", version.ref = "ktor" }
12+
ktor-client-okhttp = { module = "io.ktor:ktor-client-okhttp", version.ref = "ktor" }
1313
ktor-client-content-negotiation = { module = "io.ktor:ktor-client-content-negotiation", version.ref = "ktor" }
1414
ktor-serialization-kotlinx-json = { module = "io.ktor:ktor-serialization-kotlinx-json", version.ref = "ktor" }
1515
ktor-logging-plugin = { module = "io.ktor:ktor-client-logging", version.ref = "ktor" }

src/main/kotlin/com/ctrlhub/core/http/KtorClientFactory.kt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,14 @@ package com.ctrlhub.core.http
33
import com.ctrlhub.core.Config
44
import io.ktor.client.HttpClient
55
import io.ktor.client.HttpClientConfig
6-
import io.ktor.client.engine.cio.CIO
6+
import io.ktor.client.engine.okhttp.OkHttp
77
import io.ktor.client.plugins.UserAgent
88
import io.ktor.client.plugins.contentnegotiation.ContentNegotiation
99
import io.ktor.client.plugins.defaultRequest
1010
import io.ktor.http.HttpHeaders
1111
import io.ktor.serialization.kotlinx.json.json
1212
import io.ktor.util.appendIfNameAbsent
1313
import kotlinx.serialization.json.Json
14-
import java.util.concurrent.atomic.AtomicReference
1514

1615
/**
1716
* A wrapper around the Ktor client. This allows default configuration
@@ -20,7 +19,7 @@ import java.util.concurrent.atomic.AtomicReference
2019
*/
2120
object KtorClientFactory {
2221
fun create(
23-
httpClient: HttpClient = HttpClient(CIO),
22+
httpClient: HttpClient = HttpClient(OkHttp),
2423
configBlock: HttpClientConfig<*>.() -> Unit = {}
2524
): HttpClient {
2625
return configureHttpClient(httpClient, configBlock)

0 commit comments

Comments
 (0)