Skip to content

Commit 7498514

Browse files
committed
Avoid throwing exception on 300s
Signed-off-by: Adam Ratzman <[email protected]>
1 parent 34bb957 commit 7498514

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/commonMain/kotlin/com.adamratzman.spotify/http/HttpConnection.kt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ public class HttpConnection constructor(
9191
val httpRequest = buildRequest(additionalHeaders)
9292
if (api?.spotifyApiOptions?.enableDebugMode == true) println("DEBUG MODE: Request: $this")
9393
try {
94-
return HttpClient().request<io.ktor.client.statement.HttpResponse>(httpRequest).let { response ->
94+
return httpClient.request<io.ktor.client.statement.HttpResponse>(httpRequest).let { response ->
9595
val respCode = response.status.value
9696

9797
if (respCode in 500..599 && (retryIfInternalServerErrorLeft == null || retryIfInternalServerErrorLeft == -1 || retryIfInternalServerErrorLeft > 0)) {
@@ -216,6 +216,12 @@ public class HttpConnection constructor(
216216
|headers=${headers.toList()}
217217
| )""".trimMargin()
218218
}
219+
220+
internal companion object {
221+
internal val httpClient = HttpClient {
222+
expectSuccess = false
223+
}
224+
}
219225
}
220226

221227
public enum class HttpConnectionStatus(public val code: Int) {

0 commit comments

Comments
 (0)