From 7020e63918a7534f29edb4536c5cb2382d40175a Mon Sep 17 00:00:00 2001 From: Rudi Grinberg Date: Mon, 24 Jun 2024 01:24:31 +0100 Subject: [PATCH] chore: Apply OCamlFormat 0.26.2 (#1044) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fix bad documentation markup. Signed-off-by: Antonin Décimo Co-authored-by: Antonin Décimo --- .ocamlformat | 2 +- cohttp-async/src/server.mli | 2 +- cohttp-eio/src/server.ml | 10 +++--- cohttp-lwt-unix/src/server.mli | 2 +- cohttp-lwt/src/connection_cache.ml | 8 ++--- cohttp-lwt/src/s.ml | 53 +++++++++++++++--------------- cohttp-mirage/src/cohttp_mirage.ml | 6 ++-- cohttp/src/accept.mli | 2 +- cohttp/src/header.mli | 2 +- cohttp/src/s.ml | 2 +- http/src/http.mli | 5 ++- 11 files changed, 47 insertions(+), 47 deletions(-) diff --git a/.ocamlformat b/.ocamlformat index 0b4769bef5..1595ace957 100644 --- a/.ocamlformat +++ b/.ocamlformat @@ -1,4 +1,4 @@ -version = 0.25.1 +version = 0.26.2 profile=conventional break-infix=fit-or-vertical parse-docstrings=true diff --git a/cohttp-async/src/server.mli b/cohttp-async/src/server.mli index 8b93e9afeb..4a64b821f5 100644 --- a/cohttp-async/src/server.mli +++ b/cohttp-async/src/server.mli @@ -38,7 +38,7 @@ type response_action = val respond : response respond_t val resolve_local_file : docroot:string -> uri:Uri.t -> string - [@@deprecated "Please use Cohttp.Path.resolve_local_file. "] +[@@deprecated "Please use Cohttp.Path.resolve_local_file. "] (** Resolve a URI and a docroot into a concrete local filename. *) val respond_with_pipe : diff --git a/cohttp-eio/src/server.ml b/cohttp-eio/src/server.ml index 24ec9c2d10..1cf56b1b6d 100644 --- a/cohttp-eio/src/server.ml +++ b/cohttp-eio/src/server.ml @@ -37,7 +37,8 @@ let make_expert ?conn_closed ~callback () = let make ?(conn_closed = fun _ -> ()) ~callback () = { conn_closed; - handler = (fun conn request body _ic oc -> callback conn request body (request, oc)); + handler = + (fun conn request body _ic oc -> callback conn request body (request, oc)); } let read input = @@ -90,13 +91,14 @@ let write output (response : Cohttp.Response.t) body = in Eio.Buf_write.flush output -let respond ?(headers = Cohttp.Header.init ()) ?flush ~status ~body () (request, oc) = +let respond ?(headers = Cohttp.Header.init ()) ?flush ~status ~body () + (request, oc) = let keep_alive = Http.Request.is_keep_alive request in let headers = match Cohttp.Header.connection headers with | None -> - Http.Header.add headers "connection" - (if keep_alive then "keep-alive" else "close") + Http.Header.add headers "connection" + (if keep_alive then "keep-alive" else "close") | Some _ -> headers in let response = Cohttp.Response.make ~headers ?flush ~status () in diff --git a/cohttp-lwt-unix/src/server.mli b/cohttp-lwt-unix/src/server.mli index 8df2def108..e3643e579a 100644 --- a/cohttp-lwt-unix/src/server.mli +++ b/cohttp-lwt-unix/src/server.mli @@ -7,7 +7,7 @@ include Cohttp_lwt.S.Server with module IO = Io val resolve_file : docroot:string -> uri:Uri.t -> string - [@@deprecated "Please use Cohttp.Path.resolve_local_file. "] +[@@deprecated "Please use Cohttp.Path.resolve_local_file. "] val respond_file : ?headers:Http.Header.t -> diff --git a/cohttp-lwt/src/connection_cache.ml b/cohttp-lwt/src/connection_cache.ml index f8c80b4d35..b16e2f4c2b 100644 --- a/cohttp-lwt/src/connection_cache.ml +++ b/cohttp-lwt/src/connection_cache.ml @@ -5,10 +5,10 @@ module Make_no_cache (Connection : S.Connection) : sig include S.Connection_cache val create : ?ctx:Connection.Net.ctx -> unit -> t - (** [create ?ctx ()] creates a connection for handling a single - request. The connection accepts only a single request and will - automatically be closed as soon as possible. - @param ctx See {Connection.Net.ctx} *) + (** [create ?ctx ()] creates a connection for handling a single request. The + connection accepts only a single request and will automatically be closed + as soon as possible. + @param ctx See {!Connection.Net.ctx} *) end = struct module Net = Connection.Net module IO = Net.IO diff --git a/cohttp-lwt/src/s.ml b/cohttp-lwt/src/s.ml index 2b8bba7e6f..e7d85465ad 100644 --- a/cohttp-lwt/src/s.ml +++ b/cohttp-lwt/src/s.ml @@ -79,32 +79,31 @@ type call = Http.Method.t -> Uri.t -> (Cohttp.Response.t * Body.t) Lwt.t -(** [call ?headers ?body method uri] - Function type used to handle http requests - - @return [(response, response_body)] - [response_body] is not buffered, but stays on the wire until - consumed. It must therefore be consumed in a timely manner. - Otherwise the connection would stay open and a file descriptor leak - may be caused. Following responses would get blocked. - Functions in the {!Body} module can be used to consume [response_body]. - Use {!Body.drain_body} if you don't consume the body by other means. - - Leaks are detected by the GC and logged as debug messages, these can - be enabled activating the debug logging. For example, this can be - done as follows in [cohttp-lwt-unix] - - {[ - Cohttp_lwt_unix.Debug.activate_debug (); - Logs.set_level (Some Logs.Warning) - ]} - - @raise {!exception Connection.Retry} on recoverable errors like the remote - endpoint closing - the connection gracefully. Even non-idempotent requests are - guaranteed to not have been processed by the remote endpoint and - should be retried. But beware that a [`Stream] [body] may have been - consumed. *) +(** [call ?headers ?body method uri] Function type used to handle http requests + + @return + [(response, response_body)] [response_body] is not buffered, but stays on + the wire until consumed. It must therefore be consumed in a timely manner. + Otherwise the connection would stay open and a file descriptor leak may be + caused. Following responses would get blocked. Functions in the {!Body} + module can be used to consume [response_body]. Use {!Body.drain_body} if + you don't consume the body by other means. + + Leaks are detected by the GC and logged as debug messages, these can be + enabled activating the debug logging. For example, this can be done as + follows in + [cohttp-lwt-unix] + + {[ + Cohttp_lwt_unix.Debug.activate_debug (); + Logs.set_level (Some Logs.Warning) + ]} + + @raise {!exception:Connection.Retry} + on recoverable errors like the remote endpoint closing the connection + gracefully. Even non-idempotent requests are guaranteed to not have been + processed by the remote endpoint and should be retried. But beware that a + [`Stream] [body] may have been consumed. *) (** The [Connection] module handles a single, possibly pipelined, http connection. *) @@ -232,7 +231,7 @@ module type Server = sig and type response = Http.Response.t * Body.t val resolve_local_file : docroot:string -> uri:Uri.t -> string - [@@deprecated "Please use Cohttp.Path.resolve_local_file. "] + [@@deprecated "Please use Cohttp.Path.resolve_local_file. "] (** Resolve a URI and a docroot into a concrete local filename. *) val respond_error : diff --git a/cohttp-mirage/src/cohttp_mirage.ml b/cohttp-mirage/src/cohttp_mirage.ml index 957f7024ad..b132728388 100644 --- a/cohttp-mirage/src/cohttp_mirage.ml +++ b/cohttp-mirage/src/cohttp_mirage.ml @@ -3,9 +3,9 @@ module IO = Io.Make module Net = Net.Make -(** The resulting {modtype:Cohttp_lwt.S.Net} module can be used to build the - low-level client interfaces with {module:Cohttp_lwt.Connection.Make} and - from that {module:Cohttp_lwt.Connection_cache.Make}. *) +(** The resulting {!modtype:Cohttp_lwt.S.Net} module can be used to build the + low-level client interfaces with {!module:Cohttp_lwt.Connection.Make} and + from that {!module:Cohttp_lwt.Connection_cache.Make}. *) (** client modules *) diff --git a/cohttp/src/accept.mli b/cohttp/src/accept.mli index 6cddf1a8ee..6095fd36d1 100644 --- a/cohttp/src/accept.mli +++ b/cohttp/src/accept.mli @@ -48,7 +48,7 @@ type encoding = Accept_types.encoding = [@@deriving sexp] (** Basic language range tag. ["en-gb"] is represented as - [Language \["en"; "gb"\]]. + [Language ["en"; "gb"]]. @see the specification. *) type language = Accept_types.language = Language of string list | AnyLanguage diff --git a/cohttp/src/header.mli b/cohttp/src/header.mli index 37bf7d6d0a..ff4f7fc104 100644 --- a/cohttp/src/header.mli +++ b/cohttp/src/header.mli @@ -87,7 +87,7 @@ val replace : t -> string -> string -> t (** [replace h k v] replaces the last added value of [k] from [h] and removed all other occurences of [k] if it exists. Otherwise it adds [(k, v)] to [h]. - {e Invariant:} [forall h, k, v. get_multi (replace h k v) = \[ v \]] *) + {e Invariant:} [forall h, k, v. get_multi (replace h k v) = [ v ]] *) val mem : t -> string -> bool (** [mem h k] returns [true] if the header name [k] appears in [h] and [false] diff --git a/cohttp/src/s.ml b/cohttp/src/s.ml index 1331f8018b..85182ebbd9 100644 --- a/cohttp/src/s.ml +++ b/cohttp/src/s.ml @@ -144,7 +144,7 @@ module type Response = sig val version : t -> Code.version val status : t -> Code.status_code - val flush : (t -> bool) + val flush : t -> bool [@@deprecated "this field will be removed in the future"] val compare : t -> t -> int diff --git a/http/src/http.mli b/http/src/http.mli index 3beb0027d7..13a99954c5 100644 --- a/http/src/http.mli +++ b/http/src/http.mli @@ -248,7 +248,7 @@ module Header : sig all other occurences of [k] if it exists. Otherwise it adds [(k, v)] to [h]. - {e Invariant:} [forall h, k, v. get_multi (replace h k v) = \[ v \]] *) + {e Invariant:} [forall h, k, v. get_multi (replace h k v) = [ v ]] *) val mem : t -> string -> bool (** [mem h k] returns [true] if the header name [k] appears in [h] and [false] @@ -464,8 +464,7 @@ module Response : sig val version : t -> Version.t val status : t -> Status.t - val flush : - (t -> bool) + val flush : t -> bool [@@deprecated "this field will be removed in the future. Provide flush in the \ [respond_*] function instead."]