An OCaml webserver, but the allocating version (vs httpz which doesnt)
1(** HTTP-date parsing and formatting per RFC 7231 Section 7.1.1.1. *)
2
3(** {1 Types} *)
4
5(** Parse status. *)
6type status =
7 | Valid (** Successfully parsed *)
8 | Invalid (** Invalid date format *)
9
10(** {1 Parsing} *)
11
12(** Parse HTTP-date from span.
13 Accepts all three formats (IMF-fixdate, RFC 850, asctime).
14 Returns (status, timestamp) where timestamp is Unix seconds since epoch.
15 Only valid if status = Valid. *)
16val parse : Base_bigstring.t -> Span.t -> status * float
17
18(** {1 Formatting} *)
19
20(** Format Unix timestamp as IMF-fixdate string (allocates).
21 Example: ["Sun, 06 Nov 1994 08:49:37 GMT"] *)
22val format : float -> string
23
24(** {1 Response Writing} *)
25
26(** Write [Date: <timestamp>\r\n] header. Returns new offset. *)
27val write_date_header : Base_bigstring.t -> off:int -> float -> int
28
29(** Write [Last-Modified: <timestamp>\r\n] header. Returns new offset. *)
30val write_last_modified : Base_bigstring.t -> off:int -> float -> int
31
32(** Write [Expires: <timestamp>\r\n] header. Returns new offset. *)
33val write_expires : Base_bigstring.t -> off:int -> float -> int
34
35(** Write formatted HTTP-date at offset (no header name, no CRLF).
36 Returns new offset. Used internally by header writers. *)
37val write_http_date : Base_bigstring.t -> off:int -> float -> int
38
39(** {2 Comparison Helpers} *)
40
41(** Check if resource was modified since the given date. *)
42val is_modified_since : last_modified:float -> if_modified_since:float -> bool
43
44(** Check if resource was not modified since the given date. *)
45val is_unmodified_since : last_modified:float -> if_unmodified_since:float -> bool