Skip to content

Commit

Permalink
feat: add gzip encoding support to Ktor client
Browse files Browse the repository at this point in the history
  • Loading branch information
hua0512 committed May 14, 2024
1 parent e2e438b commit 8f398ca
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 0 deletions.
1 change: 1 addition & 0 deletions base/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ dependencies {
implementation(libs.me.tongfei.progressbar)
api(libs.io.ktor.client.core)
api(libs.io.ktor.client.cio)
implementation(libs.io.ktor.client.encoding)
api(libs.io.ktor.serialization.kotlinx.json)
api(libs.io.ktor.client.logging)

Expand Down
3 changes: 3 additions & 0 deletions base/src/main/kotlin/github/hua0512/app/App.kt
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,9 @@ class App(val json: Json) {
retryOnServerErrors(maxRetries = 5)
exponentialDelay()
}
install(ContentEncoding) {
gzip(0.9F)
}

// install(HttpCookies) {
// storage = AcceptAllCookiesStorage()
Expand Down
1 change: 1 addition & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ io-ktor-client-core = { module = "io.ktor:ktor-client-core", version.ref = "ktor
io-ktor-client-cio = { module = "io.ktor:ktor-client-cio", version.ref = "ktor" }
io-ktor-client-java = { module = "io.ktor:ktor-client-java", version.ref = "ktor" }
io-ktor-client-content-negotiation = { module = "io.ktor:ktor-client-content-negotiation", version.ref = "ktor" }
io-ktor-client-encoding = { module = "io.ktor:ktor-client-encoding", version.ref = "ktor" }
io-ktor-serialization-kotlinx-json = { module = "io.ktor:ktor-serialization-kotlinx-json", version.ref = "ktor" }
io-ktor-client-logging = { module = "io.ktor:ktor-client-logging", version.ref = "ktor" }
io-ktor-client-okhttp = { module = "io.ktor:ktor-client-okhttp", version.ref = "ktor" }
Expand Down

0 comments on commit 8f398ca

Please sign in to comment.