Hi in one of my tests I am using the OkHttp client...
# http4k
n
Hi in one of my tests I am using the OkHttp client wrapper .. for no particular reason, just to try it. Is there any way to set the connect timeout? I've tried to use ok http client directly but then I loose the compatibility with http4k requests Or are there any other http client which has the timeout config out of the box?Thanks!
I am using http4k 4.41.1.0
the current code I have is something like this:
Copy code
val httpClient = OkHttp()

val response = httpClient(request)
I would like to add (raise actually) the connect timeout
d
You need to configure the client that goes into the OkHttp wrapper constructor
It's not an http4k setting per se
n
I see
this one you mean
Copy code
operator fun invoke(
    client: OkHttpClient = defaultOkHttpClient(),
    bodyMode: BodyMode = BodyMode.Memory
): DualSyncAsyncHttpHandler =
?
a
Copy code
val client = OkHttpClient.Builder()
        .followRedirects(false)
        .callTimeout(timeout)
        .build()
        .let { OkHttp(it) }
n
thanks a lot! 👍
a
Yes, the snippet I shared is calling the function you provided with a customized OkHttpClient
n
I see... thanks!