Module Webs.Resp

module Resp: sig .. end
HTTP response.


Response body


type consumer = (bytes * int * int) option -> unit 
The type for response consumers.

Response consumers are provided by the connector to get the body produced by a response. Response bodies call the consumer with Some (byte, pos, len), to output data. The bytes are not modified by the consumer and only read from pos to pos+len. The producer signals the end of body by calling the consumer with None.

type body = 
| Stream of (consumer -> unit)
| File of (int * int) option * string
The type for response bodies.
val stream_body : (consumer -> unit) -> body
stream_body producer is a response body stream produced by producer on the consumer it will be given to.
val string_body : string -> body
string_body s is a reponse body made of string s.
val empty_body : body
empty_body s is an empty body.
val file_body : ?range:int * int -> string -> body
file_body name is a body that will contain the bytes of filename name as resolved by the connector. If range is specified as (pos, len), only the bytes from pos to pos+len will be transmitted.
val pp_body : Format.formatter -> body -> unit
pp_body ppf b prints an unspecified representation of b's specification on ppf. If body is a stream, does not consume it.

Response


type t = Webs.resp 
The type for responses.
val v : ?version:Webs.HTTP.version ->
Webs.HTTP.status -> Webs.HTTP.headers -> body -> Webs.resp
v ~version status headers body is a response with the given version (defaults to (1,1)), status, headers and body.
val version : Webs.resp -> Webs.HTTP.version
version r is r's version.
val status : Webs.resp -> Webs.HTTP.status
status r is r's status.
val headers : Webs.resp -> Webs.HTTP.headers
headers r is r's headers.
val body : Webs.resp -> body
body r is r's body.
val with_status : Webs.resp -> Webs.HTTP.status -> Webs.resp
with_status r s is r with status s.
val with_headers : Webs.resp -> Webs.HTTP.headers -> Webs.resp
with_headers r s is r with headers hs.
val with_body : Webs.resp -> body -> Webs.resp
with_body r b is r with body b.
val pp : Format.formatter -> Webs.resp -> unit
pp ppf t prints an unspecified represntation of r on ppf but guarantees not to consume the Webs.Resp.body.