An OCaml webserver, but the allocating version (vs httpz which doesnt)
1(** HTTP request type. *)
2
3(** Request record. Content headers (Content-Length, Transfer-Encoding,
4 Connection, Expect) are parsed during header parsing and cached here; they are
5 excluded from the returned header list. *)
6type t =
7 { meth : Method.t
8 ; target : Span.t
9 ; version : Version.t
10 ; body_off : int
11 ; content_length : int64 (** Content-Length value, [-1L] if not present *)
12 ; is_chunked : bool (** [true] if Transfer-Encoding: chunked *)
13 ; keep_alive : bool (** [true] for keep-alive (considers version default) *)
14 ; expect_continue : bool (** [true] if Expect: 100-continue present per
15 {{:https://datatracker.ietf.org/doc/html/rfc7231#section-5.1.1}RFC 7231 Section 5.1.1} *)
16 }
17
18(** Check if the complete body is available in the buffer. Returns [true] if body_off +
19 content_length <= len, or if there's no body. *)
20val body_in_buffer : len:int -> t -> bool
21
22(** Get span of body if fully in buffer. Returns span with [len = -1] if body incomplete
23 or chunked encoding (use {!Chunk.parse} for chunked). *)
24val body_span : len:int -> t -> Span.t
25
26(** Returns additional bytes needed for complete body, or [0] if complete. Returns [-1]
27 for chunked encoding (unknown length). *)
28val body_bytes_needed : len:int -> t -> int
29
30(** Pretty-print request line using buffer (shows actual values). *)
31val pp_with_buf : Base_bigstring.t -> Stdlib.Format.formatter -> t -> unit
32
33(** Pretty-print request structure. *)
34val pp : Stdlib.Format.formatter -> t -> unit