Module Fetch.Body

Body specification and interface.

Specification

type init

The type for specifying bodies.

val of_jstr : Jstr.t -> init

of_jstr s is a body from string s.

val of_uri_params : Brr.Uri.Params.t -> init

of_uri_params p is a body from URI params p.

val of_form_data : Form.Data.t -> init

of_form_data d is a body from form data d.

val of_blob : Brr.Blob.t -> init

of_blob b is a body from blob b.

val of_array_buffer : Brr.Tarray.Buffer.t -> init

of_array_buffer b is a body from array buffer b.

Interface

type t

The type for objects implementing the Body interface.

val body_used : t -> bool

body_used b indicates indicates if b was used.

val body : t -> Jv.t option

body b is b as a stream.

val array_buffer : t -> Brr.Tarray.Buffer.t Fut.or_error

array_buffer b reads b into an array buffer.

val blob : t -> Brr.Blob.t Fut.or_error

blob b reads b as a blob.

val form_data : t -> Form.Data.t Fut.or_error

form_data b reads b as form data.

val json : t -> Brr.Json.t Fut.or_error

json b reads b and parses it as JSON data.

val text : t -> Jstr.t Fut.or_error

text b reads b and UTF-8 decodes it to a string.