Module Webs.Req

module Req: sig .. end
HTTP requests.

HTTP Requests

type body = unit -> (bytes * int * int) option 
The type for request bodies.

A body is a function that yields byte chunks of the request body as Some (bytes, pos, len) values. The bytes value must not be modified and is readable from pos to pos+len until the next call to the function. The function returns None at the end of stream.

type t = Webs.req 
The type for HTTP requests.
val v : ?dict:Webs.dict ->
Webs.HTTP.version ->
Webs.HTTP.meth ->
path:Webs.HTTP.path ->
?query:string ->
Webs.HTTP.headers -> ?body_len:int -> body -> Webs.req
v dict v m p q hs bl b is an HTTP request with the given components. uri_query and body_len defaults to None. dict defaults to Webs.Dict.empty.
val version : Webs.req -> Webs.HTTP.version
version r is r's HTTP version.
val meth : Webs.req -> Webs.HTTP.meth
meth r is r's HTTP method.
val path : Webs.req -> Webs.HTTP.path
path r is r's HTTP request target origin-form's absolute-path. This is the requested URI's path as decoded by Webs.HTTP.decode_path.

TODO say something about the other request target cases.

val query : Webs.req -> string option
query r is r's HTTP request target origin-form's query (if any). This is the requested URI query string without the '?'. The query string may be the empty string which is different from None (no '?' in the URI).

TODO say something about decoding, make something better.

val headers : Webs.req -> Webs.HTTP.headers
headers r is r's HTTP headers. Includes at least the header.
val dict : Webs.req -> Webs.dict
dict r is r's dictionary. Initially empty it can be used be services and layers to store and share data.
val body_len : Webs.req -> int option
body_len r is r's request body length (if known).
val body : Webs.req -> body
body r is r's body.
val with_headers : Webs.req -> Webs.HTTP.headers -> Webs.req
with_headers req hs is req with headers hs.
val with_body : Webs.req -> body_len:int option -> body -> Webs.req
with_body req blen b is req with body length blen and body b. body_length defaults to None.
val with_path : Webs.req -> Webs.HTTP.path -> Webs.req
with_path req p is req with path p.
val with_dict : Webs.req -> Webs.dict -> Webs.req
with_dict req d is req with dictionary d.
val pp : Format.formatter -> Webs.req -> unit
pp ppf req prints and unspecified representation of req on ppf but guarantees not to consume the Webs.Req.body.