(** Buffer type and utilities for HTTP parsing. *) (** HTTP parsing result status. *) type status = | Complete | Partial | Invalid_method | Invalid_target | Invalid_version | Invalid_header | Headers_too_large | Malformed | Content_length_overflow (** Content-Length value too large or invalid *) | Ambiguous_framing (** Both Content-Length and Transfer-Encoding present *) | Bare_cr_detected (** CR without LF - HTTP smuggling attempt *) | Missing_host_header (** HTTP/1.1 requires Host header *) | Unsupported_transfer_encoding (** Transfer-Encoding other than chunked/identity per {{:https://datatracker.ietf.org/doc/html/rfc7230#section-3.3.1}RFC 7230 Section 3.3.1} *) (** Convert status to string representation. *) val status_to_string : status -> string (** Pretty-print status. *) val pp_status : Stdlib.Format.formatter -> status -> unit (** Maximum buffer size: 32KB. *) val buffer_size : int (** Maximum headers per request. *) val max_headers : int (** Create a new 32KB buffer. *) val create : unit -> Base_bigstring.t (** Get character at position (unchecked). *) val peek : Base_bigstring.t -> int -> char (** Check if character is valid HTTP token character. *) val is_token_char : char -> bool (** Check if character is whitespace (space or tab). *) val is_space : char -> bool (** Convert character to lowercase. *) val to_lower : char -> char (** Find CRLF sequence starting at [pos]. Returns position of CR or [-1] if not found. *) val find_crlf : Base_bigstring.t -> pos:int -> len:int -> int (** Pretty-print buffer. *) val pp : Stdlib.Format.formatter -> Base_bigstring.t -> unit (** {2 Security Limits} *) (** Configurable security limits for parsing. *) type limits = { max_content_length : int64 (** Maximum Content-Length value (default: 100MB) *) ; max_header_size : int (** Maximum size of all headers combined (default: 16KB) *) ; max_header_count : int (** Maximum number of headers (default: 100) *) ; max_chunk_size : int (** Maximum chunk size for chunked encoding (default: 16MB) *) } (** Default limits: 100MB content, 16KB headers, 100 header count, 16MB chunks. *) val default_limits : limits (** Detect bare CR (CR not followed by LF) - RFC 7230 Section 3.5. Used to prevent HTTP request smuggling attacks. *) val has_bare_cr : Base_bigstring.t -> pos:int -> len:int -> bool (** Check if a value contains CRLF injection attempt. *) val has_crlf_injection : Base_bigstring.t -> pos:int -> len:int -> bool