Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source
Source file hTTP_client.ml
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899moduletypeS=sigtypectx(** Type of the user-defined {i context}.
The context is an user-defined value which can be passed to your HTTP
client implementation to be able to tweak some internal details about the
underlying request/connection used to get an HTTP response.
For instance, an HTTP implementation can optionally require some value
such as the internal buffer size or a time-out value, etc. The interface
wants to {b allow} the implementer to pass such information via the [ctx]
type.
In others words, anything optionnaly needed to initiate/do the HTTP
request and that is not described over this interface (by arguments,
types, etc.) can be passed via the user-defined [ctx] type.
For instance, MirageOS uses this [ctx] as a ressource allocator to
initiate a TCP/IP connection or a TLS connection - and, by this way,
it fully abstracts the HTTP client implementation over the TCP/IP and
the TLS stack (for more details, see [mimic]).
Of course, [ctx = unit] if you don't need to pass extra-information when
you want to do an HTTP request/connection. *)moduleHeaders:sigtypet(** The type of HTTP headers. *)valadd:t->string->string->t(** [add hdrs key value] adds a [key] and a [value] to an existing
[hdrs] headers. *)valget:t->string->stringoption(** [get hdrs key] retrieves a [key] from the given [hdrs] headers. If the
header is one of the set of headers defined to have list values, then
all of the values are concatenated into a single string separated by
commas and returned. If it is a singleton header, then the first value
is returned and no concatenation is performed. *)valget_location:t->Uri.toption(** [get_location hdrs] is [get hdrs "location"]. *)valinit_with:string->string->t(** [init_with key value] constructs a fresh map of HTTP headers with a
single key and value entry. *)(** / *)valto_string:t->stringendmoduleBody:sigtypet(** The type of HTTP body. *)valof_string:string->t(** [of_string str] makes a body from the given [string] [str]. *)valto_string:t->stringLwt.t(** [to_string body] returns the full given [body] as a [string]. *)endmoduleResponse:sigtypet(** The type of HTTP response. *)valstatus:t->int(** [status resp] is the HTTP status code of the response [resp]. *)valheaders:t->Headers.t(** [headers resp] is headers of the response [resp]. *)endvalhead:?ctx:ctx->?headers:Headers.t->Uri.t->Response.tLwt.t(** [head ?ctx ?headers uri] sends an {i HEAD} HTTP request to the given
[uri] and returns its response. The returned response does not have
a {i body} according to the HTTP standard. *)valget:?ctx:ctx->?headers:Headers.t->Uri.t->(Response.t*Body.t)Lwt.t(** [get ?ctx ?headers uri] sends an {i GET} HTTP request to the given
[uri] and returns its response with its body. *)valpost:?ctx:ctx->?body:Body.t->?chunked:bool->?headers:Headers.t->Uri.t->(Response.t*Body.t)Lwt.t(** [post ?ctx ?body ?chunked ?headers uri] sends an {i POST} HTTP request
with the optional given [body] using chunked encoding if [chunked] is
[true] (default to [false]). It returns a response and a body. *)end