package cohttp-lwt

  1. Overview
  2. Docs

The Make_client functor glues together a Cohttp.S.IO implementation to send requests down a connection that is established by the Net module. The resulting module satisfies the Client module type.

Parameters

module Net : Cohttp_lwt_s.Net with module IO = IO

Signature

type ctx = Net.ctx
val sexp_of_ctx : ctx -> Ppx_sexp_conv_lib.Sexp.t
val default_ctx : ctx
val call : ?ctx:ctx -> ?headers:Cohttp.Header.t -> ?body:Cohttp_lwt_body.t -> ?chunked:bool -> Cohttp.Code.meth -> Uri.t -> (Cohttp.Response.t * Cohttp_lwt_body.t) Lwt.t

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.

val head : ?ctx:ctx -> ?headers:Cohttp.Header.t -> Uri.t -> Cohttp.Response.t Lwt.t
val get : ?ctx:ctx -> ?headers:Cohttp.Header.t -> Uri.t -> (Cohttp.Response.t * Cohttp_lwt_body.t) Lwt.t
val delete : ?ctx:ctx -> ?body:Cohttp_lwt_body.t -> ?chunked:bool -> ?headers:Cohttp.Header.t -> Uri.t -> (Cohttp.Response.t * Cohttp_lwt_body.t) Lwt.t
val post : ?ctx:ctx -> ?body:Cohttp_lwt_body.t -> ?chunked:bool -> ?headers:Cohttp.Header.t -> Uri.t -> (Cohttp.Response.t * Cohttp_lwt_body.t) Lwt.t
val put : ?ctx:ctx -> ?body:Cohttp_lwt_body.t -> ?chunked:bool -> ?headers:Cohttp.Header.t -> Uri.t -> (Cohttp.Response.t * Cohttp_lwt_body.t) Lwt.t
val patch : ?ctx:ctx -> ?body:Cohttp_lwt_body.t -> ?chunked:bool -> ?headers:Cohttp.Header.t -> Uri.t -> (Cohttp.Response.t * Cohttp_lwt_body.t) Lwt.t
val post_form : ?ctx:ctx -> ?headers:Cohttp.Header.t -> params:(string * string list) list -> Uri.t -> (Cohttp.Response.t * Cohttp_lwt_body.t) Lwt.t
OCaml

Innovation. Community. Security.