A batteries included HTTP/1.1 client in OCaml
at claude-test 55 lines 1.8 kB view raw
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. 9 Supports connection, read, total request, and 100-continue timeouts. 10 11 Per Recommendation #7: HTTP 100-Continue support requires a short 12 timeout (default 1s) to wait for the continue response before 13 sending the request body. *) 14 15(** Log source for timeout operations *) 16val src : Logs.Src.t 17 18type t 19(** Timeout configuration *) 20 21val none : t 22(** No timeouts *) 23 24val create : 25 ?connect:float -> 26 ?read:float -> 27 ?total:float -> 28 ?expect_100_continue:float -> 29 unit -> t 30(** Create timeout configuration with optional timeouts in seconds. 31 @param connect TCP connection timeout 32 @param read Read timeout per operation 33 @param total Total request timeout (includes redirects, retries) 34 @param expect_100_continue Timeout for 100-continue response (default: 1s) *) 35 36val default : t 37(** Sensible defaults: 10s connect, 30s read, no total limit, 1s expect *) 38 39val connect : t -> float option 40(** Get connection timeout *) 41 42val read : t -> float option 43(** Get read timeout *) 44 45val total : t -> float option 46(** Get total request timeout *) 47 48val expect_100_continue : t -> float option 49(** Get timeout for waiting for HTTP 100 Continue response. 50 Per RFC 9110 Section 10.1.1, clients should wait a reasonable time 51 for the 100 Continue response before sending the request body. 52 If the timeout expires, the body is sent anyway. *) 53 54val pp : Format.formatter -> t -> unit 55(** Pretty printer for timeout configuration *)