An OCaml library for HTTP clients and servers

Join the chat at

Cohttp is an OCaml library for creating HTTP daemons. It has a portable HTTP parser, and implementations using various asynchronous programming libraries:

  • Cohttp_lwt_unix uses the Lwt library, and specifically the UNIX bindings.
  • Cohttp_async uses the Async library.
  • Cohttp_lwt exposes an OS-independent Lwt interface, which is used by the Mirage interface to generate standalone microkernels (use the cohttp-mirage subpackage).
  • Cohttp_lwt_xhr compiles to a JavaScript module that maps the Cohttp calls to XMLHTTPRequests. This is used to compile OCaml libraries like the GitHub bindings to JavaScript and still run efficiently.

You can implement other targets using the parser very easily. Look at the IO signature in lib/s.mli and implement that in the desired backend.

You can activate some runtime debugging by setting COHTTP_DEBUG to any value, and all requests and responses will be written to stderr. Further debugging of the connection layer can be obtained by setting CONDUIT_DEBUG to any value.

21 Sep 2018
md5=8ad6bb9dffd346bd88e556fc3cffafae sha512=a5f7275c22866d24aa8e81687f7bad52e75872d655816b514996335053b5a2de9cc34f68bd077ad4059ff16b6ed3e76c02ef7f7b2e699472e42689643ade89f1
cohttp-lwt >= "1.0.0" & < "2.2.0"
cohttp >= "1.0.0" & < "2.2.0"
lwt >= "2.4.3"
mirage-kv-lwt < "2.0.0"
mirage-conduit >= "3.0.0"
conduit-lwt >= "0.99" & < "2.3.0"
conduit >= "0.99" & < "2.3.0"
dune >= "1.1.0"
ocaml >= "4.03.0"
Reverse Dependencies
git-mirage >= "1.11.4" & < "3.0.0"