Legend:
Library
Module
Module type
Parameter
Class
Class type
Library
Module
Module type
Parameter
Class
Class type
type 'body t = private {
meth : Meth.t;
host : string;
headers : Headers.t;
http_version : int * int;
path : string;
path_components : string list;
query : (string * string) list;
body : 'body;
start_time : float;
}
A request with method, path, host, headers, and a body, sent by a client.
The body is polymorphic because the request goes through several transformations. First it has no body, as only the request and headers are read; then it has a stream body; then the body might be entirely read as a string via read_body_full
.
val pp : Stdlib.Format.formatter -> string t -> unit
Pretty print the request and its body
val pp_ : Stdlib.Format.formatter -> _ t -> unit
Pretty print the request without its body
val get_header : ?f:(string -> string) -> _ t -> string -> string option
val get_header_int : _ t -> string -> int option
set_header k v req
sets k: v
in the request req
's headers.
val host : _ t -> string
Host field of the request. It also appears in the headers.
val path : _ t -> string
Request path.
val body : 'b t -> 'b
Request body, possibly empty.
val start_time : _ t -> float
time stamp (from Unix.gettimeofday
) after parsing the first line of the request
val limit_body_size : max_size:int -> byte_stream t -> byte_stream t
Limit the body size to max_size
bytes, or return a 413
error.
val read_body_full : ?buf_size:int -> byte_stream t -> string t
Read the whole body into a string. Potentially blocking.