Portable Lwt implementation of HTTP client and server, without
depending on a particular I/O implementation. The various Make
functors must be instantiated by an implementation that provides
a concrete IO monad.
The Request module combines the [root:Cohttp].Request module with
the IO functions, to have them conveniently in one place.
The Response module combines the [root:Cohttp].Request module with
the IO functions, to have them conveniently in one place.
The Client module implements non-pipelined single HTTP client
calls. Each call will open a separate Net connection. For
best results, the [root:Cohttp_lwt_body] that is returned should be
consumed in order to close the file descriptor in a timely
fashion. It will still be finalized by a GC hook if it is not used
up, but this can take some additional time to happen.
call ?ctx ?headers ?body ?chunked meth uri will resolve the
uri to a concrete network endpoint using the resolver initialized
in ctx. It will then issue an HTTP request with method meth,
adding request headers from headers if present. If a body
is specified then that will be included with the request, using
chunked encoding if chunked is true. The default is to disable
chunked encoding for HTTP request bodies for compatibility reasons.
In most cases you should use the more specific helper calls in the interface rather than invoke this function directly. See head, get and post for some examples.
The Server module implements a pipelined HTTP/1.1 server.
respond ?headers ?flush ~status ~body will respond to an HTTP
request with the given status code and response body. If
flush is true, then every response chunk will be flushed to
the network rather than being buffered. flush is true by default.