I have the following code, which is a part of a MP...
# ktor
n
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
Hi @nestserau, the bug is fixed here: https://github.com/Kotlin/kotlinx-io/pull/36
n
Cool! But which version of ktor should I use now? I’m now on 1.1.2.
c
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
I guess I’ll wait until a new version of ktor is released. Can live with this one for a while.