package tiny_httpd

  1. Overview
  2. Docs
type 'body t = {
  1. meth : Meth.t;
  2. host : string;
  3. headers : Headers.t;
  4. path : string;
  5. body : 'body;
}

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

val pp_ : Format.formatter -> _ t -> unit

Pretty print the request without its body

val headers : _ t -> Headers.t

List of headers of the request, including "Host"

val get_header : ?f:(string -> string) -> _ t -> string -> string option
val get_header_int : _ t -> string -> int option
val set_header : 'a t -> string -> string -> 'a t
val host : _ t -> string

Host field of the request. It also appears in the headers.

val meth : _ t -> Meth.t

Method for the request.

val path : _ t -> string

Request path.

val body : 'b t -> 'b

Request body, possibly empty.

val read_body_full : byte_stream t -> string t

Read the whole body into a string. Potentially blocking.

OCaml

Innovation. Community. Security.