https://kotlinlang.org logo
#ktor
Title
# ktor
r

rsetkus

10/25/2020, 3:13 PM
Hi. I'd like to dump Ktor HttResponse content. Content is
ByteReadChannel
and to get a content, I am launching coroutine and converting it to byte array like this:
Copy code
GlobalScope.launch {
    val array = response.content.toByteArray()
}
Wrote a unit test and it is failing because after converting ByteReadChannel, content gets empty. Not quite familiar with a way of reading byte channels so if anybody could point me of how to read response channel, I would much appreciate that.