Skip to content
This repository


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Very lightweight HTTP server using Lwt or Async

This branch is 0 commits ahead and 0 commits behind master

Octocat-spinner-32 async Adapt to latest Conduit API April 12, 2014
Octocat-spinner-32 bin Lwt server: improve style in arg parsing April 17, 2014
Octocat-spinner-32 cohttp make connection.t sexppable April 17, 2014
Octocat-spinner-32 examples correct filename in example February 26, 2014
Octocat-spinner-32 lib_test Add an SSL Lwt server test case alongside the TCP one April 13, 2014
Octocat-spinner-32 lwt Restore OCaml 4.00.1 compat in Cohttp_lwt by removing use of `|>` April 17, 2014
Octocat-spinner-32 scripts update type generator to use sexp January 19, 2014
Octocat-spinner-32 .gitignore ignore dist/ as generated by obuild January 26, 2013
Octocat-spinner-32 .merlin update .merlin April 04, 2014
Octocat-spinner-32 .ocp-indent ocp-indent config file for lwt February 02, 2014
Octocat-spinner-32 travis: always include sexplib/fieldslib April 17, 2014
Octocat-spinner-32 .travis.yml Travis: remove opam 1.0.0 from the tests December 11, 2013
Octocat-spinner-32 CHANGES Sync CHANGES April 17, 2014
Octocat-spinner-32 LICENSE Replace LICENSE with the ISC, which has been true of the individual January 16, 2014
Octocat-spinner-32 Makefile remove harmless build stderr warning if ocamlopt.opt is not installed April 17, 2014
Octocat-spinner-32 Note existence of cohttp-lwt-server as well April 17, 2014
Octocat-spinner-32 remove Async SSL todo April 01, 2014
Octocat-spinner-32 _oasis Merge branch 'master' of git:// into… April 17, 2014
Octocat-spinner-32 _tags Merge branch 'master' of git:// into… April 17, 2014
Octocat-spinner-32 Create a same SimpleHTTPServer with Cohttp/Lwt April 09, 2014
Octocat-spinner-32 opam Add a local opam file for easier pinning April 12, 2014
Octocat-spinner-32 Merge branch 'master' of git:// into… April 17, 2014

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 the Mirage interface to generate standalone microkernels (see the mirage-http repository).

You can implement other targets using the parser very easily. Look at the lib/IO.mli signature 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.

For build requirements, please see the _oasis file, or use OPAM to install it from

Simple HTTP server

If you install the Async dependency, then a cohttp-server-async binary will also be built and installed that acts in a similar fashion to the Python SimpleHTTPServer. Just run cohttp-server-async in a directory and it will open up a local port and serve the files over HTTP.

There is also an Lwt version of the SimpleHTTPServer installed as the cohttp-server-lwt binary. The source code for both is in the bin/ subdirectory and is a good starting point for how to write servers using the library.

Something went wrong with that request. Please try again.