forked from
anil.recoil.org/ocaml-requests
A batteries included HTTP/1.1 client in OCaml
1(*---------------------------------------------------------------------------
2 Copyright (c) 2025 Anil Madhavapeddy <anil@recoil.org>. All rights reserved.
3 SPDX-License-Identifier: ISC
4 ---------------------------------------------------------------------------*)
5
6(** Timeout configuration
7
8 This module provides timeout configuration for HTTP requests. Supports
9 connection, read, total request, and 100-continue timeouts.
10
11 Per Recommendation #7: HTTP 100-Continue support requires a short timeout
12 (default 1s) to wait for the continue response before sending the request
13 body. *)
14
15val src : Logs.Src.t
16(** Log source for timeout operations. *)
17
18type t
19(** Timeout configuration *)
20
21val none : t
22(** No timeouts. *)
23
24val v :
25 ?connect:float ->
26 ?read:float ->
27 ?total:float ->
28 ?expect_100_continue:float ->
29 unit ->
30 t
31(** [v ?connect ?read ?total ?expect_100_continue ()] creates timeout
32 configuration with optional timeouts in seconds.
33 @param connect TCP connection timeout
34 @param read Read timeout per operation
35 @param total Total request timeout (includes redirects, retries)
36 @param expect_100_continue Timeout for 100-continue response (default: 1s).
37*)
38
39val default : t
40(** Sensible defaults: 10s connect, 30s read, no total limit, 1s expect. *)
41
42val connect : t -> float option
43(** Get connection timeout. *)
44
45val read : t -> float option
46(** Get read timeout. *)
47
48val total : t -> float option
49(** Get total request timeout. *)
50
51val expect_100_continue : t -> float option
52(** Get timeout for waiting for HTTP 100 Continue response. Per RFC 9110 Section
53 10.1.1, clients should wait a reasonable time for the 100 Continue response
54 before sending the request body. If the timeout expires, the body is sent
55 anyway. *)
56
57val pp : Format.formatter -> t -> unit
58(** Pretty printer for timeout configuration. *)