Module Rock.Body
Represents an HTTP request or response body.
type content
=[
|
`Empty
|
`String of string
|
`Bigstring of Bigstringaf.t
|
`Stream of string Lwt_stream.t
]
type t
=
{
length : Stdlib.Int64.t option;
content : content;
}
t
represents an HTTP message body.
Constructor
val of_string : string -> t
of_string
creates a fixed length body from a string.
val of_bigstring : Bigstringaf.t -> t
of_bigstring
creates a fixed length body from a bigstring.
val of_stream : ?length:Stdlib.Int64.t -> string Lwt_stream.t -> t
of_stream
takes astring Lwt_stream.t
and creates a HTTP body from it.
val empty : t
empty
represents a body of size 0L.
Decoders
val to_string : t -> string Lwt.t
to_string t
returns a promise that will eventually be filled with a string representation of the body.
val to_stream : t -> string Lwt_stream.t
to_stream t
converts the body to astring Lwt_stream.t
.
Getters and Setters
val length : t -> Stdlib.Int64.t option
Utilities
val drain : t -> unit Lwt.t
drain t
will repeatedly read values from the body stream and discard them.
val sexp_of_t : t -> Sexplib0.Sexp.t
sexp_of_t t
converts the bodyt
to an s-expression
val pp : Stdlib.Format.formatter -> t -> unit
pp
formats the bodyt
as an s-expression
val pp_hum : Stdlib.Format.formatter -> t -> unit
pp_hum
formats the bodyt
as an string.If the body content is a stream, the pretty printer will output the value
"<stream>"