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;}trepresents an HTTP message body.
Constructor
val of_string : string -> tof_stringcreates a fixed length body from a string.
val of_bigstring : Bigstringaf.t -> tof_bigstringcreates a fixed length body from a bigstring.
val of_stream : ?length:Stdlib.Int64.t -> string Lwt_stream.t -> tof_streamtakes astring Lwt_stream.tand creates a HTTP body from it.
val empty : temptyrepresents a body of size 0L.
Decoders
val to_string : t -> string Lwt.tto_string treturns a promise that will eventually be filled with a string representation of the body.
val to_stream : t -> string Lwt_stream.tto_stream tconverts the body to astring Lwt_stream.t.
Getters and Setters
val length : t -> Stdlib.Int64.t option
Utilities
val drain : t -> unit Lwt.tdrain twill repeatedly read values from the body stream and discard them.
val sexp_of_t : t -> Sexplib0.Sexp.tsexp_of_t tconverts the bodytto an s-expression
val pp : Stdlib.Format.formatter -> t -> unitppformats the bodytas an s-expression
val pp_hum : Stdlib.Format.formatter -> t -> unitpp_humformats the bodytas an string.If the body content is a stream, the pretty printer will output the value
"<stream>"