package http_async

  1. Overview
  2. Docs

Service is the core abstraction that represents an HTTP server within http_async.

type request
val sexp_of_request : request -> Sexplib0.Sexp.t
type response
val sexp_of_response : response -> Sexplib0.Sexp.t

t is a function that takes a HTTP request and returns a deferred HTTP response.

val resource : request -> string

resource returns the path and query for a given request.

val meth : request -> Meth.t

meth returns the HTTP verb for a given request.

body returns the HTTP request body for a given request.

val header : request -> string -> string option

header request key returns the last header value associates with key if one exists.

val header_multi : request -> string -> string list

header_multi request key returns a list of all header values associated with key.

val respond_string : ?headers:(string * string) list -> ?status:Status.t -> string -> response Async.Deferred.t

respond_string creates a new fixed length encoded response from the user provided string. If the user provided headers don't contain a Content-Length header, one is added with the value set to the string's length.

val respond_bigstring : ?headers:(string * string) list -> ?status:Status.t -> Core.Bigstring.t -> response Async.Deferred.t

respond_bigstring creates a new fixed length encoded response from the user provided Bigstring.t. If the user provided headers don't contain a Content-Length header, one is added with the value set to the bigstring's length.

val respond_stream : ?headers:(string * string) list -> ?status:Status.t -> Core.Bigstring.t Core_unix.IOVec.t Async.Pipe.Reader.t -> response Async.Deferred.t

respond_stream creates a new streaming response. The data is chunk-encoded before its sent over the wire.