MultipartReader
This was copied from OkHttp and slightly modified to work in a Multiplatform project.
Original source: https://github.com/square/okhttp/blob/parent-4.9.2/okhttp/src/main/kotlin/okhttp3/MultipartReader.kt
Reads a stream of RFC 2046 multipart body parts. Callers read parts one-at-a-time until nextPart returns null. After calling nextPart any preceding parts should not be read.
Typical use loops over the parts in sequence:
val response: Response = call.execute()
val multipartReader = MultipartReader(response.body!!)
multipartReader.use {
while (true) {
val part = multipartReader.nextPart() ?: break
process(part.headers, part.body)
}
}
Note that nextPart will skip any unprocessed data from the preceding part. If the preceding part is particularly large or if the underlying source is particularly slow, the nextPart call may be slow!
Closing a part does not close this multipart reader; callers must explicitly close this with close.
Constructors
Types
A single part in a multipart body.