Set default request timeout and made it configurable

This commit is contained in:
dankito 2024-08-14 13:25:55 +02:00
parent 0ac6059306
commit 2fde62e2cd
1 changed files with 9 additions and 2 deletions

View File

@ -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
}
}