package shuttle_http

  1. Overview
  2. Docs

Module Shuttle_http.RequestSource

Sourcetype t

t Represents a HTTP 1.1 request.

Sourceval sexp_of_t : t -> Sexplib0.Sexp.t
Sourceval create : ?version:Version.t -> ?headers:(string * string) list -> ?body:Body.t -> Meth.t -> string -> t
Sourceval meth : t -> Meth.t

meth returns the HTTP method of this request.

Sourceval path : t -> string

path returns the path component and query parameters of the request URI

Sourceval version : t -> Version.t

version returns the HTTP version number for the request.

Sourceval headers : t -> (string * string) list

headers returns HTTP headers of this request.

Sourceval body : t -> Body.t

body returns the body payload of this request.

Sourceval with_body : t -> Body.t -> t

with_body returns a new request where every value is the same as the input request but the body is replaced with the function input.

Sourceval transfer_encoding : t -> [> `Bad_request | `Chunked | `Fixed of int ]

transfer_encoding returns the inferred transfer encoding based on the request's http headers.

Sourceval keep_alive : t -> bool

keep_alive indicates whether the http connection should be reused.

Sourceval add_transfer_encoding : t -> [ `Chunked | `Fixed of int ] -> t

add_transfer_encoding t encoding adds transfer-encoding information to the request headers.

Sourceval iter_headers : t -> f:(key:string -> data:string -> unit) -> unit

iter_headers t ~f iterates over all request headers and forwards them to the user provided callback.

Sourceval add_header_unless_exists : t -> key:string -> data:string -> t

add_header_unless_exists t ~key ~data returns a request with a new header added to it if the header isn't already present in the request.

Sourceval add_header : t -> key:string -> data:string -> t

add_header t ~key ~data returns a request with a new header added to it.

Sourceval header : t -> string -> string option

header t key returns Some data if key is found in the list of request headers. It returns None if the requested header isn't found.

Sourceval header_multi : t -> string -> string list

header_multi t key returns a list of all values associated with the request header name. It returns an empty list if the requested header isn't found.

Sourceval remove_header : t -> string -> t

remove_header t key removes all request headers that match the user provided key.

Sourceval header_exists : t -> string -> bool

header_exists t key returns if a request header matches the user provided key.