Is the response body read async, even with the OkH...
# ktor
d
Is the response body read async, even with the OkHttp engine (I'm currently interested in downloads) @orangy? How stable is CIO?
t
For okhttp it is probably easier to check sources :)
d
Ktor has byte channels that seem to be using Coroutines, the thing is whether that also needs a thread pool to run on, or is the implementation all async...
j
OkHttp is all blocking I/O on its own pool
👍🏼 1
d
So it's not possible to read the response body async... the docs are a bit misleading then:
Copy code
val readChannel = response.call.receive<ByteReadChannel>()
val inputStream = response.call.receive<InputStream>() Remember that InputStream API is synchronous!
Sounds like
readChannel
is async...
j
I suspect the body is read on OkHttp's pool and sent over the channel to user code
j
That's for sending the request, not reading the response
d
Oh,
OutgoingContent
... so there's still a bit of hope that it's async, I don't see the response code there...
g
that it’s async
It is async of course. Are you talking about syncronous/asyncronous or about blocking/non-blocking? Because Ktor uses syncronous blocking API of OkHttp (it doesn’t have any non-blocking one) that blocking but on own thread pool, but this API wrapped to asyncronous coroutines
d
Thanks, I meant non-blocking, so even reading response content is done blocking? I'm not so familiar with Nio to know whether the fact they use it under the hood is also blocking. I knew for sure the request and initial response is blocking. @gildor