package cohttp-lwt-unix

  1. Overview
  2. Docs

Basic satisfaction of Cohttp_lwt.Net

type ctx = {
  1. ctx : Conduit_lwt_unix.ctx;
  2. resolver : Resolver_lwt.t;
}
include Cohttp_lwt.S.Net with module IO = Cohttp_lwt_unix__.Io and type ctx := ctx and type endp = Conduit.endp
module IO : sig ... end

The Io module contains the IO implementation for cohttp-lwt-unix.

type endp = Conduit.endp
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
val init : ?ctx:Conduit_lwt_unix.ctx -> ?resolver:Resolver_lwt.t -> unit -> ctx

init ?ctx ?resolver () is a network context that is the same as the default_ctx, but with either the connection handling or resolution module overridden with ctx or resolver respectively. This is useful to supply a Conduit_lwt_unix.resolver with a custom source network interface, or a Resolver_lwt.t with a different name resolution strategy (for instance to override a hostname to point it to a Unix domain socket).

OCaml

Innovation. Community. Security.