package https-eio

  1. Overview
  2. Docs
Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source

Module Https_eioSource

Sourcetype error = [
  1. | `Msg of string
]

TLS/CA setup errors, matching ca-certs' and tls's own error shape. HTTPS connections fail closed if no system CA bundle can be found; certificate verification is never silently disabled.

The exact shape cohttp-eio's client expects for its ~https hook.

Sourceval https_for_uri : Uri.t -> (https_wrapper option, error) result

Return Some wrapper for https:// URIs, None otherwise. HTTPS URIs must include a DNS hostname accepted by domain-name; invalid hosts return Error _ before any TLS handshake. The returned wrapper captures the validated host for SNI/certificate verification.

Sourceval error_to_string : error -> string

Human-readable error text suitable for logs.

Sourcetype request_error =
  1. | Invalid_config of string
    (*

    Invalid timeout, or url is not an absolute http:///https:// URL with a host — rejected before any I/O.

    *)
  2. | Tls_setup of string
    (*

    TLS setup failed for an https:// URL.

    *)
  3. | Timeout of float
    (*

    The request did not complete within this many seconds.

    *)
  4. | Response_too_large of int
    (*

    The response body exceeded max_response_bytes (this case's int). A predictable request-policy outcome, not a transport failure — distinct from Network_error so a caller that wants to treat "the document is too big" differently from "the connection broke" can.

    *)
  5. | Network_error of string
    (*

    Connection failure, or any other transport-level exception.

    *)
Sourceval request_error_to_string : request_error -> string
Sourceval request : net:_ Eio.Net.t -> clock:_ Eio.Time.clock -> ?timeout:float -> meth:Http.Method.t -> url:string -> ?headers:(string * string) list -> ?body:string -> ?max_response_bytes:int -> unit -> (int * string, request_error) result

A timeout-bounded HTTP request through https_for_uri's TLS wrapper, on cohttp-eio. Returns (status, body) for any response, 2xx or not — callers classify status codes themselves, the same way https_for_uri leaves TLS/certificate policy to its caller. Eio.Cancel.Cancelled is always re-raised, never converted to Error.

Not a general-purpose HTTP client: no retries, no connection pooling (a fresh connection is made per call), no redirect handling. Built for the shape every non-AWS caller in this ecosystem already needed — metrics/log push, schema-registry and admin API calls, JWKS fetch — not as a replacement for cohttp-eio itself. Callers with different needs (SigV4 byte-fidelity, streaming bodies, connection reuse) should keep building their own transport.