package tiny_httpd
Module Tiny_httpd_core.RequestSource
Requests
Requests are sent by a client, e.g. a web browser or cURL. From the point of view of the server, they're inputs.
type 'body t = private {meth : Meth.t;(*HTTP method for this request.
*)host : string;client_addr : Unix.sockaddr;(*Client address. Available since 0.14.
*)headers : Headers.t;(*List of headers.
*)mutable meta : Hmap.t;(*Metadata.
*)http_version : int * int;(*HTTP version. This should be either
*)1, 0or1, 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;(*Obtained via
*)get_time_sincreate
}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_with :
?mask_header:(string -> bool) ->
?headers_to_mask:string list ->
?show_query:bool ->
?pp_body:(Format.formatter -> 'body -> unit) ->
unit ->
Format.formatter ->
'body t ->
unitPretty print the request. The exact format of this printing is not specified.
Pretty print the request and its body. The exact format of this printing is not specified.
Pretty print the request without its body. The exact format of this printing is not specified.
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.
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.
time stamp (from Unix.gettimeofday) after parsing the first line of the request
Limit the body size to max_size bytes, or return a 413 error.
Read the whole body into a string. Potentially blocking.