ContentSource

Interface for a body class that allows users to consume its body content.

Inheritors

Properties

Link copied to clipboard
abstract val contentLength: Long?

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

Link copied to clipboard
abstract 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
abstract suspend fun consumeContent(): ByteSource

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

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.