This commit is contained in:
Simon Cruanes 2023-06-09 21:04:03 -04:00
parent c6141c8b3d
commit 73899acdf2
No known key found for this signature in database
GPG key ID: EBFFF6F283F3A2B4

View file

@ -1,6 +1,7 @@
(** {1 Core signatures and implementation} *) (** Core signatures and implementation *)
(** Configuration for the client. *)
module Config : sig module Config : sig
type t type t
val default : t val default : t
@ -16,17 +17,21 @@ module Config : sig
end end
type t = Curl.t type t = Curl.t
(** A client, i.e. a cURL instance. *)
val make : val make :
?set_opts:(t -> unit) -> ?set_opts:(t -> unit) ->
unit -> t unit -> t
(** Create a new client.
@param set_opts called before returning the client, to set options *)
val delete : t -> unit val delete : t -> unit
(** Delete the client. It cannot be used anymore. *)
val with_client : val with_client :
?set_opts:(t -> unit) -> ?set_opts:(t -> unit) ->
(t -> 'a) -> 'a (t -> 'a) -> 'a
(** Make a temporary client, call the function with it, then cleanup *) (** Make a temporary client, call the function with it, then cleanup. *)
(* TODO: duphandle is deprecated, how do we iterate on options? (* TODO: duphandle is deprecated, how do we iterate on options?
val copy : t -> t val copy : t -> t
@ -34,18 +39,28 @@ val copy : t -> t
type response_info = { type response_info = {
ri_response_time: float; ri_response_time: float;
(** Total time (in seconds) for the request/response pair.
See {!Curl.get_totaltime}. *)
ri_redirect_count: int; ri_redirect_count: int;
(** Number of redirects cURL followed.
See {!Curl.get_redirectcount}. *)
} }
(** Metadata about a response from the server. *)
val pp_response_info : Format.formatter -> response_info -> unit val pp_response_info : Format.formatter -> response_info -> unit
val string_of_response_info : response_info -> string val string_of_response_info : response_info -> string
type response = { type response = {
code: int; code: int;
(** Response code. See https://developer.mozilla.org/en-US/docs/Web/HTTP/Status *)
headers: (string * string) list; headers: (string * string) list;
(** Response headers *)
body: string; body: string;
(** Response body, or [""] *)
info: response_info; info: response_info;
(** Information about the response *)
} }
(** Response for a given request. *)
val pp_response : Format.formatter -> response -> unit val pp_response : Format.formatter -> response -> unit
val string_of_response : response -> string val string_of_response : response -> string