Module Server.Request

module Config : sig ... end
module Reqd : Request.REQD with type t = Httpaf.Reqd.t
type 'ctx t

A request. 'ctx is the type of the request context which can be updated by setting a new context. It is recommended to do so in a way that preserves the old context (if there is one), e.g. inside an OCaml object with a prev method that points to the old context.

val body : unit t -> Piaf.Body.t

body(request) gets the request body. There is a chance that the body may already have been read, in which case trying to read it again will error. However in a normal request pipeline as bodies are read by filters, that should be minimized.

val body_form_raw : ?buf_size:int -> unit t -> ((string * string list) list, string) Lwt_result.t

body_form_raw(?buf_size, request) returns the request body form decoded into an association list, internally using a buffer of size buf_size with a default configured by ReWeb.Config.S.buf_size.

  • since 0.7.0
val body_string : ?buf_size:int -> unit t -> string Lwt.t

body_string(?buf_size, request) returns the request body converted into a string, internally using a buffer of size buf_size with a default configured by ReWeb.Config.S.buf_size.

val context : 'ctx t -> 'ctx
val cookies : _ t -> (string * string) list
val header : string -> _ t -> string option

header(name, request) gets the last value corresponding to the given header, if present.

val headers : string -> _ t -> string list

headers(name, request) gets all the values corresponding to the given header.

val make : string -> Reqd.t -> unit t

make(query, reqd) returns a new request containing the given query and Httpaf reqd.

val meth : _ t -> Httpaf.Method.t

meth(request) gets the request method (`GET, `POST, etc.).

val query : _ t -> string

query(request) gets the query string of the request. This is anything following the ? in the request path, otherwise an empty string.

val set_context : 'ctx2 -> 'ctx1 t -> 'ctx2 t

set_context(ctx, request) is an updated request with the given context ctx.