scoop:scoop.http.asyncio:0.1.0
src/multipart/part_writer.scoop
Selected production source · src/multipart/part_writer.scoop
1
package scoop.http.asyncio3
import scoop.asyncio.*4
import scoop.http.MultipartPartHead5
import scoop.platform.memory.NativeByteBuffer7
/**8
* The active multipart output part. Finish writes its boundary; flush does not end the part.9
*/10
public class MultipartPartWriter internal constructor(private val writer: MultipartWriter,11
/**12
* The header selected when this part began.13
*/14
public val head: MultipartPartHead)15
: AsyncByteSink, AsyncCloseable {16
internal var complete: Boolean = false17
internal var closed: Boolean = false18
/**19
* Whether this body or message reached its successful boundary.20
*/21
public val isComplete: Boolean get() = complete22
/**23
* Whether this body or message has been closed.24
*/25
public val isClosed: Boolean get() = closed || writer.io.isClosed26
/**27
* Writes body bytes into the active part.28
*/29
public override suspend fun writeFrom(buffer: NativeByteBuffer, count: Long): Long = writer.write(this, buffer, count)30
/**31
* Flushes part output without writing the end boundary.32
*/33
public override suspend fun flush() { writer.flush(Some(this)) }34
/**35
* Completes this part so the next part or final multipart boundary can be written.36
*/37
public suspend fun finish() { writer.finishPart(this) }38
/**39
* Closes the part writer; incomplete output is not silently marked complete.40
*/41
public override suspend fun close() { writer.closePart(this) }42
}