package cohttp-lwt

  1. Overview
  2. Docs
module IO : S.IO
type endp
type ctx

Conduit context. Contains configuration of resolver, local source address, TLS / SSL library, certificates, keys.

Depending on ctx, the library is able to send HTTP requests unencrypted or encrypted one with a secured protocol (such as TLS). Depending on how conduit is configured, ctx might initiate a secured connection with TLS (using ocaml-tls) or SSL (using ocaml-ssl), on *:443 or on the specified port by the user. If neitehr ocaml-tls or ocaml-ssl are installed on the system, cohttp/conduit tries the usual (*:80) or the specified port by the user in a non-secured way.

val sexp_of_ctx : ctx -> Sexplib0.Sexp.t
val default_ctx : ctx
val resolve : ctx:ctx -> Uri.t -> endp IO.t

resolve ~ctx uri resolves uri into an endpoint description. This is Resolver_lwt.resolve_uri ~uri ctx.resolver.

val connect_uri : ctx:ctx -> Uri.t -> (IO.conn * IO.ic * IO.oc) IO.t

connect_uri ~ctx uri starts a flow on the given uri. The choice of the protocol (with or without encryption) is done by the scheme of the given uri:

  • If the scheme is https, we will extend ctx to be able to start a TLS connection with a default TLS configuration (no authentication) on the default or user-specified port.
  • If the scheme is http, we will extend ctx to be able to start a simple TCP/IP connection on the default or user-specified port.

These extensions have the highest priority (Conduit will try to initiate a communication with them first). By extension, we mean that the user is able to fill its own ctx and we don't overlap resolution functions from the given ctx.

This is resolve ~ctx uri >>= connect_endp ~ctx.

val connect_endp : ctx:ctx -> endp -> (IO.conn * IO.ic * IO.oc) IO.t

connect_endp ~ctx endp starts a flow to the given endp. endp describes address and protocol of the endpoint to connect to.

val close_in : IO.ic -> unit
val close_out : IO.oc -> unit
val close : IO.ic -> IO.oc -> unit
OCaml

Innovation. Community. Security.