Legend:
Library
Module
Module type
Parameter
Class
Class type
Library
Module
Module type
Parameter
Class
Class type
type 'body t = private {
meth : Meth.t;
HTTP method for this request.
*)host : string;
headers : Headers.t;
List of headers.
*)http_version : int * int;
HTTP version. This should be either 1, 0
or 1, 1
.
path : string;
Full path of the requested URL.
*)path_components : string list;
Components of the path of the requested URL.
*)query : (string * string) list;
Query part of the requested URL.
*)body : 'body;
Body of the request.
*)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 : Format.formatter -> string t -> unit
Pretty print the request and its body. The exact format of this printing is not specified.
val pp_ : Format.formatter -> _ t -> unit
Pretty print the request without its body. The exact format of this printing is not specified.
val get_header : ?f:(string -> string) -> _ t -> string -> string option
get_header req h
looks up header h
in req
. It returns None
if the header is not present. This is case insensitive and should be used rather than looking up h
verbatim in headers
.
val get_header_int : _ t -> string -> int option
Same as get_header
but also performs a string to integer conversion.
set_header k v req
sets k: v
in the request req
's headers.
Modify headers using the given function.
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.