package shuttle_http

  1. Overview
  2. Docs
type t

t Represents a HTTP 1.1 response.

val sexp_of_t : t -> Sexplib0.Sexp.t
val create : ?version:Version.t -> ?reason_phrase:string -> ?headers:(string * string) list -> ?body:Body.t -> Status.t -> t
val version : t -> Version.t

version returns the HTTP version number for the response.

val status : t -> Status.t

status returns the Status code for this response.

val reason_phrase : t -> string

reason_phrase returns the status reason phrase for the response.

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

headers returns the HTTP headers for this response.

val body : t -> Body.t

body returns the body payload of this response.

val with_body : t -> Body.t -> t

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

val transfer_encoding : t -> [> `Bad_response | `Chunked | `Fixed of int ]

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

val keep_alive : t -> bool

keep_alive indicates whether the http connection should be reused.

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

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

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

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

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

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

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

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

val header : t -> string -> string option

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

val header_multi : t -> string -> string list

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

val remove_header : t -> string -> t

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

val header_exists : t -> string -> bool

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

OCaml

Innovation. Community. Security.