HttpBody

sealed class HttpBody

HTTP payload to be sent to a peer

Inheritors

Types

Link copied to clipboard
abstract class Bytes : HttpBody

Variant of a HttpBody with payload represented as ByteArray

Link copied to clipboard
abstract class ChannelContent : HttpBody

Variant of an HttpBody with a streaming payload read from an SdkByteReadChannel

Link copied to clipboard
object Companion
Link copied to clipboard
object Empty : HttpBody

Variant of a HttpBody without a payload

Link copied to clipboard
abstract class SourceContent : HttpBody

Variant of an HttpBody with a streaming payload read from an SdkSource

Properties

Link copied to clipboard
open val contentLength: Long? = null

Specifies the length of this HttpBody content If null it is assumed to be a streaming source using e.g. Transfer-Encoding: Chunked

Link copied to clipboard
open val isDuplex: Boolean = false

Flag indicating that this request body should be handled as a duplex stream by the underlying engine.

Link copied to clipboard
open val isOneShot: Boolean = true

Flag indicating the body can be consumed only once

Inherited properties

Functions

Link copied to clipboard
open operator override fun equals(other: Any?): Boolean

Inherited functions

Link copied to clipboard
suspend fun HttpBody.readAll(): ByteArray?

Consume the HttpBody and pull the entire contents into memory as a ByteArray. Only do this if you are sure the contents fit in-memory as this will read the entire contents of a streaming variant.

Link copied to clipboard
fun HttpBody.toByteStream(): <Error class: unknown class>?

Convert an HttpBody variant to the corresponding ByteStream variant or null if empty.

Link copied to clipboard
fun HttpBody.toCompletingBody(deferred: <Error class: unknown class><String>): HttpBody

Convert an HttpBody with an underlying HashingSource or HashingByteReadChannel to a CompletingSource or CompletingByteReadChannel, respectively.

Link copied to clipboard
fun HttpBody.toHashingBody(hashFunction: <Error class: unknown class>, contentLength: Long?): HttpBody

Convert an HttpBody.SourceContent or HttpBody.ChannelContent to a body with a HashingSource or HashingByteReadChannel, respectively.

Link copied to clipboard
fun HttpBody.toSdkByteReadChannel(scope: <Error class: unknown class>? = null): <Error class: unknown class>?

Convenience function to treat all HttpBody variants with a payload as an SdkByteReadChannel