class RequestBody
source · line 19public class RequestBody internal constructor(
contentLength: Long?,
/**
* The body's media type, if supplied.
*/
public val contentType: HttpMediaType?,
private val plan: RequestBodyPlan,
contentEncodings: List<String> = emptyList<String>(),
internal val trailerDeclaration: HttpTrailerDeclaration =
HttpTrailerDeclaration(emptyList<String>()),
internal val entityDigests: Array<ClientEntityDigest> = []
)
A request-body plan with explicit metadata and replayability. One-shot sources cannot be retried after consumption; factories reopen state without implicit whole-body buffering.
property contentEncodings
source · line 38public val contentEncodings: Array<String>
get: public read-only
Content codings applied to the outgoing body, in application order.
property contentLength
source · line 34public val contentLength: Long?
get: public read-only
The declared outgoing representation length, or None when unknown.
function writeWithTrailersTo
source · line 87public suspend fun writeWithTrailersTo(destination: AsyncByteSink, bufferSize: Long = 8192L): RequestBodyWriteResult
Writes and length-checks the body, then returns transferred bytes and validated declared trailers.
parameter destination
source · line 88destination: AsyncByteSink
parameter bufferSize
source · line 89bufferSize: Long = 8192L
property trailerNames
source · line 42public val trailerNames: Array<String>
get: public read-only
The declared names that the producer may return as trailers.
getter get
source · line 42get(): Array<String>
function withDigest
source · line 60public fun withDigest(algorithm: HttpDigestAlgorithm, bytes: List<Byte>): RequestBody
Adds an explicit entity digest for the selected authentication algorithm; the caller supplies bytes matching the actual body.
parameter bytes
source · line 60bytes: List<Byte>
parameter algorithm
source · line 60algorithm: HttpDigestAlgorithm
property isReplayable
source · line 46public val isReplayable: Boolean
get: public read-only
Whether the plan can create a fresh body traversal for another attempt.
getter get
source · line 46get(): Boolean
property contentType
source · line 24public val contentType: HttpMediaType?
get: public read-only
The body's media type, if supplied.
function writeTo
source · line 74public suspend fun writeTo(destination: AsyncByteSink, bufferSize: Long = 8192L): Long
Writes the body to a borrowed sink and verifies declared length; bodies declaring trailers require writeWithTrailersTo.
parameter bufferSize
source · line 74bufferSize: Long = 8192L
parameter destination
source · line 74destination: AsyncByteSink
function compressed
source · line 52public fun compressed(options: CompressionOptions = CompressionOptions.Gzip(GzipOptions())): RequestBody
Wraps this plan in streaming compression, preserving its replayability and updating coding metadata.
parameter options
source · line 53options: CompressionOptions = CompressionOptions.Gzip(GzipOptions())