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

Julius

12/08/2023, 5:13 AM
Hey! I have an issue with creating a progress bar with ktor client in javascript using
onDownload
as described in the documentation here: https://ktor.io/docs/response.html#raw I have this code:
Copy code
httpClient.get(url) {
                        onDownload { bytesSentTotal: Long, contentLength: Long ->
                            println("Downloaded $bytesSentTotal bytes out of $contentLength at time ${Clock.System.now()}")
                        }
                    }
In the browser, this first downloads the whole file and emits all the console logs at once after the download has already finished. I'm attaching part of the log to show how all the logs were emitted in less than a seconds while the actual download of the file took more than 7 seconds. Is there something I'm doing wrong here or another fix to this? I'm using ktor version 2.3.7 Edit: I seem to be able to replicate this issue on jvm as well 👀 🎉 Found the cause, it was the ktor
HttpCache
plugin! Should I open an issue for this?
a

Aleksei Tirman [JB]

12/08/2023, 9:18 AM
Please file the issue with the code snippet for JVM attached.
5 Views