package http-lwt-client

  1. Overview
  2. Docs
A simple HTTP client using http/af, h2, and lwt

Install

Dune Dependency

Authors

Maintainers

Sources

http-lwt-client-0.2.1.tbz
sha256=c34733e1546794d93e9d0560d1633c0818a9677965d2157078dd8d1635c25cfb
sha512=2c16d3d3867bcdedb80d658b94d7219b91a3ffdffe4efd16887d04e55b68faa04108953bc5bf20775b97af18a2c3208e8338c1c2da70c3d21fd7db8b77f2cfbf

doc/http-lwt-client/Http_lwt_client/index.html

Module Http_lwt_clientSource

HTTP lwt client

A HTTP client using the lwt task library. It does a single HTTP request (though may follow redirects) to a remote uri. Both HTTP protocol 1.1 and 2.0 are supported. Both http and https (via the pure implementation OCaml-TLS) are supported. A connection is established via the happy-eyeballs algorithm.

Sourcemodule Version = Httpaf.Version

Protocol Version

Sourcemodule Status = H2.Status

Response Status Codes

Sourcemodule Headers = H2.Headers

Header fields

Sourcetype response = {
  1. version : Version.t;
  2. status : Status.t;
  3. reason : string;
  4. headers : Headers.t;
}

A response, consisting of version, status, reason (HTTP 1 only), and headers.

Sourceval pp_response : Format.formatter -> response -> unit

pp_response ppf response pretty-prints the response on ppf.

Sourceval request : ?config:[ `HTTP_1_1 of Httpaf.Config.t | `H2 of H2.Config.t ] -> ?tls_config:Tls.Config.client -> ?authenticator:X509.Authenticator.t -> ?meth:Httpaf.Method.t -> ?headers:(string * string) list -> ?body:string -> ?max_redirect:int -> ?follow_redirect:bool -> ?happy_eyeballs:Happy_eyeballs_lwt.t -> string -> (response -> 'a -> string -> 'a Lwt.t) -> 'a -> (response * 'a, [> `Msg of string ]) Lwt_result.t

request ~config ~authenticator ~meth ~headers ~body ~max_redirect ~follow_redirect ~happy_eyeballs uri f init does a single request of uri and returns the response. Each time part of the body is received, f acc part is called, with acc being the last return value of f (or init if it is the first time) and part being the body part received.

By default, up to 5 redirects (max_redirect) are followed. If follow_redirect is false, no redirect is followed (defaults to true). The default HTTP request type (meth) is GET.

If no tls_config is provided, a default one is used, with alpn and authenticators. If a tls_config is provided, this is used unmodified.

If no config is provided (the default), and the uri uses the https schema, application layer next protocol negotiation (ALPN) is used to negotiate HTTP2 (prefered) or HTTP1. If the uri uses the http schema, HTTP1 is used by default (unless the config provided is `H2).

The default authenticator is from the ca-certs opam package, which discovers and uses the system trust anchors.

The happy-eyeballs opam package is used to establish the TCP connection, which prefers IPv6 over IPv4.

OCaml

Innovation. Community. Security.