Body

The body of a request or response.

Note that its contents can only be consumed once, via the ByteSource returned by consumeContent.

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard
open override val contentLength: Long?

The size, in bytes, of the content, if known / provided ahead of time (or null otherwise).

Link copied to clipboard
open override val contentType: String

The content type that describes the bytes owned by this body.

Functions

Link copied to clipboard
suspend fun ContentSource.bytes(limit: Int? = null): ByteArray

Convenience method to convert a body's content into a raw byte array.

Link copied to clipboard
open suspend override fun consumeContent(): ByteSource

Open an async stream up that consumes the content of this body.

Link copied to clipboard
suspend fun multipart(): Multipart

Fetch details for this body's content IF its content is split up into multipart sections

Link copied to clipboard

Convert this byte source into an InputStream.

Link copied to clipboard
suspend fun ContentSource.text(charset: Charset = contentType.parseCharsetFromContentType(), limit: Int? = null): String

Convenience method to convert a body's content into a UTF-8 string.