package http-lwt-client
Install
dune-project
Dependency
Authors
Maintainers
Sources
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.
Protocol Version
Header fields
A response, consisting of version, status, reason (HTTP 1 only), and headers.
pp_response ppf response pretty-prints the response on ppf.
val 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.trequest ~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.