Set default request timeout and made it configurable
This commit is contained in:
parent
0ac6059306
commit
2fde62e2cd
|
@ -1,6 +1,7 @@
|
||||||
package net.dankito.banking.fints.webclient
|
package net.dankito.banking.fints.webclient
|
||||||
|
|
||||||
import io.ktor.client.HttpClient
|
import io.ktor.client.HttpClient
|
||||||
|
import io.ktor.client.plugins.*
|
||||||
import io.ktor.client.request.post
|
import io.ktor.client.request.post
|
||||||
import io.ktor.client.request.setBody
|
import io.ktor.client.request.setBody
|
||||||
import io.ktor.client.statement.bodyAsText
|
import io.ktor.client.statement.bodyAsText
|
||||||
|
@ -10,13 +11,19 @@ import kotlinx.coroutines.cancel
|
||||||
import net.codinux.log.logger
|
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()
|
private val log by logger()
|
||||||
|
|
||||||
|
|
||||||
protected val client = HttpClient {
|
protected val client = HttpClient {
|
||||||
|
install(HttpTimeout) {
|
||||||
|
this.connectTimeoutMillis = connectTimeoutMillis
|
||||||
|
this.requestTimeoutMillis = requestTimeoutMillis
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue