Skip to content

Commit 19ebec7

Browse files
committed
Update to Ktor 1.2.0
1 parent 149769b commit 19ebec7

File tree

21 files changed

+46
-46
lines changed

21 files changed

+46
-46
lines changed

build.gradle.kts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ kotlin {
4040
api(Ktor("client-logging"))
4141
api(Ktor("client-core"))
4242
api(Ktor("client-json"))
43+
api(Ktor("client-serialization"))
4344
}
4445
}
4546
val commonTest by getting {
@@ -55,6 +56,7 @@ kotlin {
5556
api(Ktor("client-core-jvm"))
5657
api(Ktor("client-json-jvm"))
5758
api(Ktor("client-logging-jvm"))
59+
api(Ktor("client-serialization-jvm"))
5860
}
5961
}
6062
val jvmTest by getting {

buildSrc/src/main/kotlin/Ktor.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@ object Ktor : Dependency {
22

33
override val group = "io.ktor"
44
override val artifact = "ktor"
5-
override val version = "1.1.5"
5+
override val version = "1.2.0"
66
}

docs/ExceptionHandling.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ However, an HTTP exception can occur. Handle it with a try / catch block.
1515
```kotlin
1616
try {
1717
val response = index.search()
18-
} catch (exception: BadResponseStatusException) {
18+
} catch (exception: ResponseException) {
1919
when (exception.response.status) {
2020
HttpStatusCode.NotFound -> TODO()
2121
HttpStatusCode.BadRequest -> TODO()
@@ -30,7 +30,7 @@ Other kinds of exceptions can occur. Handle them appropriately.
3030
```kotlin
3131
try {
3232
val response = index.search()
33-
} catch (exception: BadResponseStatusException) {
33+
} catch (exception: ResponseException) {
3434
TODO()
3535
} catch (exception: IOException) {
3636
TODO()

src/commonMain/kotlin/com/algolia/search/client/ClientAccount.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ package com.algolia.search.client
22

33
import com.algolia.search.model.ApplicationID
44
import com.algolia.search.model.task.Task
5-
import io.ktor.client.features.BadResponseStatusException
5+
import io.ktor.client.features.ResponseException
66
import io.ktor.http.HttpStatusCode
77

88

@@ -23,7 +23,7 @@ public object ClientAccount {
2323
var hasThrown404 = false
2424
try {
2525
destination.getSettings()
26-
} catch (exception: BadResponseStatusException) {
26+
} catch (exception: ResponseException) {
2727
hasThrown404 = exception.response.status.value == HttpStatusCode.NotFound.value
2828
if (!hasThrown404) throw exception
2929
}

src/commonMain/kotlin/com/algolia/search/client/ClientSearch.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ import com.algolia.search.serialize.KeyType
2727
import com.algolia.search.serialize.RouteLogs
2828
import com.algolia.search.transport.RequestOptions
2929
import com.algolia.search.transport.Transport
30-
import io.ktor.client.features.BadResponseStatusException
30+
import io.ktor.client.features.ResponseException
3131
import io.ktor.client.features.logging.LogLevel
3232
import io.ktor.http.HttpMethod
3333
import io.ktor.http.HttpStatusCode
@@ -104,7 +104,7 @@ public class ClientSearch private constructor(
104104
while (true) {
105105
try {
106106
return getAPIKey(apiKey)
107-
} catch (exception: BadResponseStatusException) {
107+
} catch (exception: ResponseException) {
108108
if (exception.response.status.value != HttpStatusCode.NotFound.value) throw exception
109109
}
110110
delay(1000L)
@@ -126,7 +126,7 @@ public class ClientSearch private constructor(
126126
while (true) {
127127
try {
128128
getAPIKey(apiKey)
129-
} catch (exception: BadResponseStatusException) {
129+
} catch (exception: ResponseException) {
130130
if (exception.response.status.value == HttpStatusCode.NotFound.value) return true else throw exception
131131
}
132132
delay(1000L)

src/commonMain/kotlin/com/algolia/search/configuration/Extensions.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ import io.ktor.client.features.logging.LogLevel
55

66
internal const val defaultWriteTimeout: Long = 30000L
77
internal const val defaultReadTimeout: Long = 2000L
8-
internal val defaultLogLevel = LogLevel.INFO
8+
internal val defaultLogLevel = LogLevel.NONE
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
package com.algolia.search.helper
22

3-
import io.ktor.client.features.BadResponseStatusException
3+
import io.ktor.client.features.ResponseException
44
import io.ktor.client.response.readBytes
55
import kotlinx.io.core.String
66

77

88
/**
9-
* Convenience method to convert [BadResponseStatusException.response] body bytes to a [String].
9+
* Convenience method to convert [ResponseException.response] body bytes to a [String].
1010
*/
11-
suspend fun BadResponseStatusException.readContent(): String {
11+
suspend fun ResponseException.readContent(): String {
1212
return String(response.readBytes())
1313
}

src/commonMain/kotlin/com/algolia/search/model/search/IgnorePlurals.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package com.algolia.search.model.search
22

3-
import com.algolia.search.serialize.JsonNonStrict
43
import com.algolia.search.model.settings.Settings
4+
import com.algolia.search.serialize.JsonNonStrict
55
import com.algolia.search.serialize.asJsonInput
66
import kotlinx.serialization.*
77
import kotlinx.serialization.internal.BooleanSerializer

src/commonMain/kotlin/com/algolia/search/model/search/RemoveStopWords.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package com.algolia.search.model.search
22

3-
import com.algolia.search.serialize.JsonNonStrict
43
import com.algolia.search.model.settings.Settings
4+
import com.algolia.search.serialize.JsonNonStrict
55
import com.algolia.search.serialize.asJsonInput
66
import kotlinx.serialization.*
77
import kotlinx.serialization.internal.BooleanSerializer

src/commonMain/kotlin/com/algolia/search/transport/Transport.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package com.algolia.search.transport
33
import com.algolia.search.configuration.CallType
44
import com.algolia.search.configuration.Configuration
55
import com.algolia.search.configuration.RetryableHost
6-
import io.ktor.client.features.BadResponseStatusException
6+
import io.ktor.client.features.ResponseException
77
import io.ktor.client.request.HttpRequestBuilder
88
import io.ktor.client.request.request
99
import io.ktor.http.HttpMethod
@@ -75,7 +75,7 @@ internal class Transport(
7575
mutex.withLock { host.hasTimedOut() }
7676
} catch (exception: IOException) {
7777
mutex.withLock { host.hasFailed() }
78-
} catch (exception: BadResponseStatusException) {
78+
} catch (exception: ResponseException) {
7979
val isRetryable = floor(exception.response.status.value / 100f) != 4f
8080

8181
if (isRetryable) mutex.withLock { host.hasFailed() } else throw exception

0 commit comments

Comments
 (0)