Http_versionHTTP protocol version identification and ALPN support.
This module provides types for HTTP protocol versions and utilities for TLS Application-Layer Protocol Negotiation (ALPN) as specified in RFC 9113 Section 3.1.
Per RFC 9113 Section 3.1:
"h2" identifies HTTP/2 over TLS"http/1.1" identifies HTTP/1.1 (* Configure TLS with HTTP/2 preference *)
let alpn = Http_version.alpn_protocols ~preferred:[Http_2; Http_1_1] in
(* alpn = ["h2"; "http/1.1"] *)val to_string : t -> stringto_string version returns a human-readable string. Examples: "HTTP/1.0", "HTTP/1.1", "HTTP/2"
val pp : Format.formatter -> t -> unitPretty printer for versions.
Per RFC 9113 Section 3.1.
"h2" - ALPN protocol identifier for HTTP/2 over TLS. Serialized as the two-octet sequence: 0x68, 0x32.
val alpn_of_version : t -> string optionalpn_of_version version returns the ALPN identifier for a version. Returns None for HTTP/1.0 which has no ALPN identifier.
val version_of_alpn : string -> t optionversion_of_alpn alpn returns the version for an ALPN identifier. Returns None for unrecognized identifiers.
val alpn_protocols : preferred:t list -> string listalpn_protocols ~preferred returns ALPN protocol identifiers in preference order. HTTP/1.0 is filtered out (no ALPN identifier).
Example:
alpn_protocols ~preferred:[Http_2; Http_1_1]
(* Returns: ["h2"; "http/1.1"] *)val supports_multiplexing : t -> boolsupports_multiplexing version returns true if the version supports request multiplexing over a single connection. Only HTTP/2 supports this.
val supports_server_push : t -> boolsupports_server_push version returns true if the version supports server push. Only HTTP/2 supports this.
val supports_header_compression : t -> boolsupports_header_compression version returns true if the version supports header compression. Only HTTP/2 (HPACK) supports this.