//okhttp/okhttp3/MultipartReader
MultipartReader¶
[jvm]\ class MultipartReaderconstructor(source: BufferedSource, val boundary: String) : Closeable
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¶
MultipartReader | [jvm] fun MultipartReader(response: ResponseBody) |
MultipartReader | [jvm] fun MultipartReader(source: BufferedSource, boundary: String) |
Types¶
Name | Summary |
---|---|
Part | [jvm] class Part(val headers: Headers, val body: BufferedSource) : Closeable A single part in a multipart body. |
Functions¶
Name | Summary |
---|---|
close | [jvm] open override fun close() |
nextPart | [jvm] fun nextPart(): MultipartReader.Part? |
Properties¶
Name | Summary |
---|---|
boundary | [jvm] @get:JvmName(name = "boundary") val boundary: String |