Module S.Body

Request-body constructors for this runtime adapter.

type 'a io = 'a io
type t = request_body

Runtime request body descriptor.

Values may be replayable, such as in-memory or file-backed bodies, or one-shot, such as bodies backed by a caller-owned stream.

type writer

Scoped writer passed to streaming body callbacks.

The writer is valid only while the callback supplied to of_stream is running. Do not store it or use it after the callback returns.

val empty : t

Empty replayable body with content length 0.

val of_string : string -> t

Build a replayable in-memory body from a string.

val of_bytes : bytes -> t

Build a replayable in-memory body from bytes.

val of_stream : content_length:int64 -> replayable:bool -> write:(writer -> (unit, Awskit.Error.t) Stdlib.result io) -> (t, Awskit.Error.t) Stdlib.result

Build a streaming request body with a known content_length.

replayable must be true only when retrying the request can recreate the same bytes by invoking write again. Negative content lengths are rejected before a request is sent. The supplied writer is scoped to one invocation of write.

val content_length : t -> int64 option

Return the known content length for the body, when available.

val replayable : t -> bool

Return whether the body can be safely written again for retries.

module Writer : sig ... end