https://kotlinlang.org logo
Title
i

Ifvwm

01/14/2021, 5:52 AM
why take a HttpResponse from a download link would take a long time?
val client = HttpClient(CIO) {
        followRedirects = false
    }
        val _result = client.get<HttpResponse>(addr)
        val readInputStream = client.get<InputStream>(_result.headers["LOCATION"]?:"")
//        val count = client.get<HttpResponse>(_result.headers["LOCATION"]?:"")
the comment line would take 20 seconds
g

gildor

01/14/2021, 6:26 AM
do you have any reproduction for this?
r

Rustam Siniukov

01/14/2021, 11:48 AM
client.get<HttpResponse>
downloads and saves in memory body of the response. If you don’t need it, use
client.get<HttpStatement>().execute { /* you can read body here */ }
👍 1