Skip to content

Commit

Permalink
Switch to OkHttp as http client on jvm (#928)
Browse files Browse the repository at this point in the history
Closes #771
  • Loading branch information
DRSchlaubi authored Mar 20, 2024
1 parent 76c5474 commit 7350a21
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion common/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ kotlin {
}
jvmMain {
dependencies {
api(libs.ktor.client.cio)
api(libs.ktor.client.okhttp)
}
}
nonJvmMain {
Expand Down
4 changes: 2 additions & 2 deletions common/src/jvmMain/kotlin/http/HttpEngine.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ package dev.kord.common.http

import dev.kord.common.annotation.KordInternal
import io.ktor.client.engine.*
import io.ktor.client.engine.cio.*
import io.ktor.client.engine.okhttp.OkHttp

/** @suppress */
@KordInternal
public actual fun httpEngine(): HttpClientEngineFactory<HttpClientEngineConfig> = CIO
public actual fun httpEngine(): HttpClientEngineFactory<HttpClientEngineConfig> = OkHttp
2 changes: 1 addition & 1 deletion gateway/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ suspend fun main(args: Array<String>) {
val token = args.firstOrNull() ?: error("token required")

val gateway = DefaultGateway { // optional builder for custom configuration
client = HttpClient(CIO) {
client = HttpClient {
install(WebSockets)
install(JsonFeature)
}
Expand Down
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ ktor-client-content-negotiation = { module = "io.ktor:ktor-client-content-negoti
ktor-serialization-kotlinx-json = { module = "io.ktor:ktor-serialization-kotlinx-json", version.ref = "ktor" }
ktor-client-core = { module = "io.ktor:ktor-client-core", version.ref = "ktor" }
ktor-client-js = { module = "io.ktor:ktor-client-js", version.ref = "ktor" }
ktor-client-cio = { module = "io.ktor:ktor-client-cio", version.ref = "ktor" }
ktor-client-okhttp = { module = "io.ktor:ktor-client-okhttp", version.ref = "ktor" }
ktor-client-websockets = { module = "io.ktor:ktor-client-websockets", version.ref = "ktor" }
ktor-client-mock = { module = "io.ktor:ktor-client-mock", version.ref = "ktor" }
ktor-network = { module = "io.ktor:ktor-network", version.ref = "ktor" }
Expand Down
4 changes: 2 additions & 2 deletions voice/src/main/kotlin/gateway/DefaultVoiceGatewayBuilder.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import dev.kord.common.entity.Snowflake
import dev.kord.gateway.retry.LinearRetry
import dev.kord.gateway.retry.Retry
import io.ktor.client.*
import io.ktor.client.engine.cio.*
import io.ktor.client.engine.okhttp.OkHttp
import io.ktor.client.plugins.contentnegotiation.*
import io.ktor.client.plugins.websocket.*
import io.ktor.serialization.kotlinx.json.*
Expand All @@ -23,7 +23,7 @@ public class DefaultVoiceGatewayBuilder(
public var eventFlow: MutableSharedFlow<VoiceEvent> = MutableSharedFlow(extraBufferCapacity = Int.MAX_VALUE)

public fun build(): DefaultVoiceGateway {
val client = client ?: HttpClient(CIO) {
val client = client ?: HttpClient(OkHttp) {
install(WebSockets)
install(ContentNegotiation) {
json()
Expand Down

0 comments on commit 7350a21

Please sign in to comment.