I’ve an issue with chunked switch encoding in iOS. That is the KMM code:
non-public const val DEFAULT_BUFFER_SIZE: Int = 8 * 1024
inside val shopper = HttpClient()
enjoyable readChunkedData(url: String, onChunk: (String) -> Unit): Job {
val scope = MainScope()
return scope.launch {
shopper.preparePost(url).execute {
val channel: ByteReadChannel = it.physique()
whereas (!channel.isClosedForRead) {
val buffer = ByteArray(DEFAULT_BUFFER_SIZE)
channel.readAvailable(buffer)
val trimmed = buffer
.dropLastWhile { b -> b == 0.toByte() }
.toByteArray()
.map { c -> Char(c.toInt()) }
.toCharArray()
onChunk(trimmed.concatToString())
}
}
}
}
iOS use Darwin engine and Android Okhttp for Ktor
In Android this code works positive:
However in iOS isn’t working as anticipated (as a substitute of studying chunks is awaiting the entire response):
Is any answer to repair it? I used to be attempting to make use of CIO engine however getting one other subject in iOS: TLS periods will not be supported on Native platform.