I'm perplexed with behavior here: ```val byteArra...
# ktor
I'm perplexed with behavior here:
Copy code
val byteArray = ByteArray(throwable.response.content.availableForRead)
val text = String(byteArray, 0, byteArray.size, Charsets.UTF_8)
When debugging and stepping through it reads the response fine. Without stepping through
is an empty String. Seems like a race condition. Will
stream the complete content? Or is there some sort of waiting that must be done for the request to complete?
well, it does appear to be a race condition in that code. Odd, because it is a suspend function I expected it to complete successfully before returning. I suppose it only reads what is in the buffer at the time...solution was this:
Copy code
val text = String(throwable.response.content.toByteArray())