From 2fde62e2cd2cb32aab2f1d3c46be38a25f32c719 Mon Sep 17 00:00:00 2001 From: dankito Date: Wed, 14 Aug 2024 13:25:55 +0200 Subject: [PATCH] Set default request timeout and made it configurable --- .../dankito/banking/fints/webclient/KtorWebClient.kt | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/webclient/KtorWebClient.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/webclient/KtorWebClient.kt index 8f231e06..2c72b580 100644 --- a/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/webclient/KtorWebClient.kt +++ b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/webclient/KtorWebClient.kt @@ -1,6 +1,7 @@ package net.dankito.banking.fints.webclient import io.ktor.client.HttpClient +import io.ktor.client.plugins.* import io.ktor.client.request.post import io.ktor.client.request.setBody import io.ktor.client.statement.bodyAsText @@ -10,13 +11,19 @@ import kotlinx.coroutines.cancel import net.codinux.log.logger -open class KtorWebClient : IWebClient { +open class KtorWebClient( + connectTimeoutMillis: Long = 10_000, + requestTimeoutMillis: Long = 60_000 +) : IWebClient { private val log by logger() protected val client = HttpClient { - + install(HttpTimeout) { + this.connectTimeoutMillis = connectTimeoutMillis + this.requestTimeoutMillis = requestTimeoutMillis + } }