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

nestserau

02/07/2019, 2:11 PM
I have the following code, which is a part of a MPP library which I now use from iOS. The problem is that sometimes the size of
input
gets less than intended, in other words I don’t get the data in its entirety. Via Wireshark I’ve verified that the problem is not on the backend side, I always receive the same amount of bytes via the network interface and the bytes are also the same. But in 1-10% of cases
input
is shorter than intended.
Copy code
private val client = HttpClient()

suspend fun <T> send(...): ... {

        val response: HttpResponse

        try {
            response = <http://client.post|client.post>(url) { body = payload }
        } catch (e: Throwable) {
            ...
        }

        if (response.status != HttpStatusCode.OK) {
            return ...
        }

        val input = response.readBytes().asUByteArray()
        ...
}
Thoughts?
e

e5l

02/07/2019, 2:12 PM
Hi @nestserau, the bug is fixed here: https://github.com/Kotlin/kotlinx-io/pull/36
n

nestserau

02/07/2019, 2:15 PM
Cool! But which version of ktor should I use now? I’m now on 1.1.2.
c

cy

02/07/2019, 2:18 PM
You can try dev build or kotlinx.io for now since it is not yet released:
"org.jetbrains.kotlinx:kotlinx-io:0.1.5-dev-4"
n

nestserau

02/07/2019, 2:33 PM
I guess I’ll wait until a new version of ktor is released. Can live with this one for a while.
2 Views