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(** Response limits for HTTP protocol handling
7
8 Configurable limits for response body size, header count, and header length
9 to prevent DoS attacks. *)
10
11type t
12(** Abstract type representing HTTP response limits. *)
13
14val default : t
15(** Default limits:
16 - max_response_body_size: 100MB
17 - max_header_size: 16KB
18 - max_header_count: 100
19 - max_decompressed_size: 100MB
20 - max_compression_ratio: 100:1. *)
21
22val v :
23 ?max_response_body_size:int64 ->
24 ?max_header_size:int ->
25 ?max_header_count:int ->
26 ?max_decompressed_size:int64 ->
27 ?max_compression_ratio:float ->
28 unit ->
29 t
30(** [v ?max_response_body_size ?max_header_size ?max_header_count
31 ?max_decompressed_size ?max_compression_ratio ()] creates custom response
32 limits. All parameters are optional and default to the values in {!default}.
33*)
34
35val max_response_body_size : t -> int64
36(** Maximum response body size in bytes. *)
37
38val max_header_size : t -> int
39(** Maximum size of a single header line in bytes. *)
40
41val max_header_count : t -> int
42(** Maximum number of headers allowed. *)
43
44val max_decompressed_size : t -> int64
45(** Maximum decompressed size in bytes. *)
46
47val max_compression_ratio : t -> float
48(** Maximum compression ratio allowed (e.g., 100.0 means 100:1). *)
49
50val pp : Format.formatter -> t -> unit
51(** Pretty-printer for response limits. *)
52
53val to_string : t -> string
54(** Convert response limits to a human-readable string. *)