An OCaml webserver, but the allocating version (vs httpz which doesnt)
1(** Error handling combinators for HTTP parsing. *)
2
3(** {1 Status Type} *)
4
5(** Re-export of parse status for convenience *)
6type status = Buf_read.status =
7 | Complete
8 | Partial
9 | Invalid_method
10 | Invalid_target
11 | Invalid_version
12 | Invalid_header
13 | Headers_too_large
14 | Malformed
15 | Content_length_overflow
16 | Ambiguous_framing
17 | Bare_cr_detected
18 | Missing_host_header
19 | Unsupported_transfer_encoding
20
21(** {1 Exception} *)
22
23(** Parse error with detailed status *)
24exception Parse_error of status
25
26(** {1 Direct Fail Combinators} *)
27
28(** [fail status] raises [Parse_error status]. *)
29val fail : status -> 'a
30
31(** [partial ()] raises [Parse_error Partial]. Use when more input is needed. *)
32val partial : unit -> 'a
33
34(** [malformed ()] raises [Parse_error Malformed]. Use for format violations. *)
35val malformed : unit -> 'a
36
37(** {1 Conditional Raises (when condition is TRUE)} *)
38
39(** [when_ cond status] raises [Parse_error status] if [cond] is true. *)
40val when_ : bool -> status -> unit
41
42(** [partial_when cond] raises [Parse_error Partial] if [cond] is true. *)
43val partial_when : bool -> unit
44
45(** [malformed_when cond] raises [Parse_error Malformed] if [cond] is true. *)
46val malformed_when : bool -> unit
47
48(** {1 Guard Combinators (raise when condition is FALSE)} *)
49
50(** [guard cond status] raises [Parse_error status] if [cond] is false. *)
51val guard : bool -> status -> unit
52
53(** [partial_unless cond] raises [Parse_error Partial] if [cond] is false. *)
54val partial_unless : bool -> unit
55
56(** [malformed_unless cond] raises [Parse_error Malformed] if [cond] is false. *)
57val malformed_unless : bool -> unit
58
59(** {1 Recovery Combinator} *)
60
61(** [optional ~save ~restore f] tries to run [f ()]. On success, returns
62 [Some result]. On [Parse_error], restores state and returns [None]. *)
63val optional : save:(unit -> 'pos) -> restore:('pos -> unit) -> (unit -> 'a) -> 'a option