package shuttle_http

  1. Overview
  2. Docs

Module Shuttle_http.ResponseSource

Sourcetype t

t Represents a HTTP 1.1 response.

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

version returns the HTTP version number for the response.

Sourceval status : t -> Status.t

status returns the Status code for this response.

Sourceval reason_phrase : t -> string

reason_phrase returns the status reason phrase for the response.

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

headers returns the HTTP headers for this response.

Sourceval body : t -> Body.t

body returns the body payload of this response.

Sourceval 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.

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

transfer_encoding returns the inferred transfer encoding based on the response'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 response headers.

Sourceval 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.

Sourceval 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.

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

add_header t ~key ~data returns a response 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 response 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 response 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 response headers that match the user provided key.

Sourceval header_exists : t -> string -> bool

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

OCaml

Innovation. Community. Security.