6

I'm using the Ktor HttpClient(CIO) to make requests against an HTTP API whose response uses chunked transfer encoding.

Is there a way using the Ktor HttpClient(CIO) to get access to the individual Http Chunks in an HttpResponse, when calling an API that uses chunked transfer encoding?

1 Answers1

0

I guess better late than never:

httpClient.prepareGet("http://localhost:8080/").execute {
    val channel = it.bodyAsChannel()
    while (!channel.isClosedForRead) {
        val chunk = channel.readUTF8Line() ?: break
        println(chunk)
    }
}