RequestBody

class RequestBody(bytes: ByteArray, val contentType: String?)(source)

A request body: its bytes and an optional content type.

Stable Core. The constructor's shape is frozen. The bytes are copied in and read back as copies. Equality is identity. toString() prints the size and whether a content type is set, never the bytes or the type.

Parameters

bytes

the body; copied.

contentType

an RFC 9110 media type (its visible-ASCII subset), or null for none.

Throws

if contentType is not a media type; the message holds the failing index, not the text.

Constructors

Link copied to clipboard
constructor(bytes: ByteArray, contentType: String?)

Properties

Link copied to clipboard

The media type, or null for none.

Link copied to clipboard
val size: Int

The body's size in bytes.

Functions

Link copied to clipboard

Returns the body.

Link copied to clipboard
open override fun toString(): String

A diagnostic string for logs: the size and whether a content type is set, never the bytes. Its format is not part of the API and may change.