package rock

  1. Overview
  2. Docs
Minimalist framework to build extensible HTTP servers and clients

Install

Dune Dependency

Authors

Maintainers

Sources

opium-0.20.0.tbz
sha256=326b91866de90baf535f8b7d4b2ff23e39d952e573c04b3c13f1054b59ff2fb6
sha512=59b83e7c8fe5f7ae328fb7f2343fe5b8fb735e8f6ee263cfd6c75bb179688ef7cf2b4586b35a2231ed3f3c1ada543021b7a4759326ae095eb77a5f38b9fa3a8a

doc/rock/Rock/Body/index.html

Module Rock.BodySource

Represents an HTTP request or response body.

Sourcetype content = [
  1. | `Empty
  2. | `String of string
  3. | `Bigstring of Bigstringaf.t
  4. | `Stream of string Lwt_stream.t
]
Sourcetype t = {
  1. length : Int64.t option;
  2. content : content;
}

t represents an HTTP message body.

Constructor

Sourceval of_string : string -> t

of_string creates a fixed length body from a string.

Sourceval of_bigstring : Bigstringaf.t -> t

of_bigstring creates a fixed length body from a bigstring.

Sourceval of_stream : ?length:Int64.t -> string Lwt_stream.t -> t

of_stream takes a string Lwt_stream.t and creates a HTTP body from it.

Sourceval empty : t

empty represents a body of size 0L.

Sourceval copy : t -> t

copy t creates a new instance of the body t. If the body is a stream, it is be duplicated safely and the initial stream will remain untouched.

Decoders

Sourceval to_string : t -> string Lwt.t

to_string t returns a promise that will eventually be filled with a string representation of the body.

Sourceval to_stream : t -> string Lwt_stream.t

to_stream t converts the body to a string Lwt_stream.t.

Getters and Setters

Sourceval length : t -> Int64.t option

Utilities

Sourceval drain : t -> unit Lwt.t

drain t will repeatedly read values from the body stream and discard them.

Sourceval sexp_of_t : t -> Sexplib0.Sexp.t

sexp_of_t t converts the body t to an s-expression

Sourceval pp : Format.formatter -> t -> unit

pp formats the body t as an s-expression

Sourceval pp_hum : Format.formatter -> t -> unit

pp_hum formats the body t as an string.

If the body content is a stream, the pretty printer will output the value "<stream>"

OCaml

Innovation. Community. Security.