Skip to content

Commit 2d6b7b7

Browse files
authored
Merge pull request mirage#1098 from smorimoto/ocamlformat-0.27
Update ocamlformat to 0.27.0
2 parents 11abd0c + a6961e8 commit 2d6b7b7

File tree

14 files changed

+92
-86
lines changed

14 files changed

+92
-86
lines changed

.ocamlformat

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
version = 0.26.2
1+
version=0.27.0
22
profile=conventional
33
break-infix=fit-or-vertical
44
parse-docstrings=true

cohttp-async/bin/cohttp_server_async.ml

+3-3
Original file line numberDiff line numberDiff line change
@@ -116,9 +116,9 @@ let start_server docroot port index cert_file key_file verbose () =
116116
Server.create
117117
~on_handler_error:
118118
(`Call
119-
(fun addr exn ->
120-
Logs.err (fun f -> f "Error from %s" (Socket.Address.to_string addr));
121-
Logs.err (fun f -> f "%s" @@ Exn.to_string exn)))
119+
(fun addr exn ->
120+
Logs.err (fun f -> f "Error from %s" (Socket.Address.to_string addr));
121+
Logs.err (fun f -> f "%s" @@ Exn.to_string exn)))
122122
~mode
123123
(Tcp.Where_to_listen.of_port port)
124124
(handler ~info ~docroot ~index)

cohttp-async/test/test_async_integration.ml

+21-21
Original file line numberDiff line numberDiff line change
@@ -28,27 +28,27 @@ let server =
2828
]
2929
(* pipelined_chunk *)
3030
@ (response_bodies |> List.map ~f:(Fn.compose const ok))
31-
@ (* large response chunked *)
32-
[
33-
(fun _ _ ->
34-
let body =
35-
let r, w = Pipe.create () in
36-
let chunk = chunk chunk_size in
37-
for _ = 0 to chunks - 1 do
38-
Pipe.write_without_pushback w chunk
39-
done;
40-
Pipe.close w;
41-
r
42-
in
43-
Server.respond_with_pipe ~code:`OK body >>| response);
44-
(* pipelined_expert *)
45-
expert (fun _ic oc ->
46-
Async_unix.Writer.write oc "8\r\nexpert 1\r\n0\r\n\r\n";
47-
Async_unix.Writer.flushed oc);
48-
expert (fun ic oc ->
49-
Async_unix.Writer.write oc "8\r\nexpert 2\r\n0\r\n\r\n";
50-
Async_unix.Writer.flushed oc >>= fun () -> Async_unix.Reader.close ic);
51-
]
31+
(* large response chunked *)
32+
@ [
33+
(fun _ _ ->
34+
let body =
35+
let r, w = Pipe.create () in
36+
let chunk = chunk chunk_size in
37+
for _ = 0 to chunks - 1 do
38+
Pipe.write_without_pushback w chunk
39+
done;
40+
Pipe.close w;
41+
r
42+
in
43+
Server.respond_with_pipe ~code:`OK body >>| response);
44+
(* pipelined_expert *)
45+
expert (fun _ic oc ->
46+
Async_unix.Writer.write oc "8\r\nexpert 1\r\n0\r\n\r\n";
47+
Async_unix.Writer.flushed oc);
48+
expert (fun ic oc ->
49+
Async_unix.Writer.write oc "8\r\nexpert 2\r\n0\r\n\r\n";
50+
Async_unix.Writer.flushed oc >>= fun () -> Async_unix.Reader.close ic);
51+
]
5252
|> response_sequence
5353

5454
let ts =

cohttp-lwt-jsoo/src/cohttp_lwt_jsoo.ml

+15-17
Original file line numberDiff line numberDiff line change
@@ -63,11 +63,11 @@ module Body_builder (P : Params) = struct
6363
let chunkerizer () =
6464
if !pos = body_len then Lwt.return C.Transfer.Done
6565
else if !pos + P.chunk_size >= body_len then (
66-
let str = text ## (substring_toEnd !pos) in
66+
let str = text##(substring_toEnd !pos) in
6767
pos := body_len;
6868
Lwt.return (C.Transfer.Final_chunk (P.convert_body_string str)))
6969
else
70-
let str = text ## (substring !pos (!pos + P.chunk_size)) in
70+
let str = text##(substring !pos (!pos + P.chunk_size)) in
7171
pos := !pos + P.chunk_size;
7272
Lwt.return (C.Transfer.Chunk (P.convert_body_string str))
7373
in
@@ -205,11 +205,10 @@ module Make_client_async (P : Params) = Make_api (struct
205205
xml##.responseType := Js.string "arraybuffer";
206206
let (res : (Http.Response.t Lwt.t * CLB.t) Lwt.t), wake = Lwt.task () in
207207
let () =
208-
xml
209-
## (_open
210-
(Js.string (C.Code.string_of_method meth))
211-
(Js.string (Uri.to_string uri))
212-
Js._true)
208+
xml##(_open
209+
(Js.string (C.Code.string_of_method meth))
210+
(Js.string (Uri.to_string uri))
211+
Js._true)
213212
(* asynchronous call *)
214213
in
215214
(* set request headers *)
@@ -221,7 +220,7 @@ module Make_client_async (P : Params) = Make_api (struct
221220
(fun k v ->
222221
(* some headers lead to errors in the javascript console, should
223222
we filter then out here? *)
224-
xml ## (setRequestHeader (Js.string k) (Js.string v)))
223+
xml##(setRequestHeader (Js.string k) (Js.string v)))
225224
headers
226225
in
227226

@@ -264,7 +263,7 @@ module Make_client_async (P : Params) = Make_api (struct
264263

265264
(* perform call *)
266265
(match body with
267-
| None -> Lwt.return xml ## (send Js.null)
266+
| None -> Lwt.return xml##(send Js.null)
268267
| Some body ->
269268
CLB.to_string body >>= fun body ->
270269
let bs = binary_string body in
@@ -292,11 +291,10 @@ module Make_client_sync (P : Params) = Make_api (struct
292291
if Lazy.force xhr_response_supported then
293292
xml##.responseType := Js.string "arraybuffer";
294293
let () =
295-
xml
296-
## (_open
297-
(Js.string (C.Code.string_of_method meth))
298-
(Js.string (Uri.to_string uri))
299-
Js._false)
294+
xml##(_open
295+
(Js.string (C.Code.string_of_method meth))
296+
(Js.string (Uri.to_string uri))
297+
Js._false)
300298
(* synchronous call *)
301299
in
302300
(* set request headers *)
@@ -308,16 +306,16 @@ module Make_client_sync (P : Params) = Make_api (struct
308306
(fun k v ->
309307
(* some headers lead to errors in the javascript console, should
310308
we filter then out here? *)
311-
xml ## (setRequestHeader (Js.string k) (Js.string v)))
309+
xml##(setRequestHeader (Js.string k) (Js.string v)))
312310
headers
313311
in
314312
(* perform call *)
315313
(match body with
316-
| None -> Lwt.return xml ## (send Js.null)
314+
| None -> Lwt.return xml##(send Js.null)
317315
| Some body ->
318316
CLB.to_string body >|= fun body ->
319317
let bs = binary_string body in
320-
xml ## (send (Js.Opt.return (Obj.magic bs))))
318+
xml##(send (Js.Opt.return (Obj.magic bs))))
321319
>>= fun _body ->
322320
let body = Bb.construct_body xml in
323321
(* (re-)construct the response *)

cohttp-lwt-unix/test/test_sanity.ml

+12-12
Original file line numberDiff line numberDiff line change
@@ -50,22 +50,22 @@ let server =
5050
(fun _ _ ->
5151
Lwt.return
5252
(`Expert
53-
(let headers =
54-
Http.(
55-
Header.add_transfer_encoding (Header.init ()) Transfer.Chunked)
56-
in
57-
( Http.Response.make ~headers (),
58-
fun _ic oc -> Lwt_io.write oc "8\r\nexpert 1\r\n0\r\n\r\n" ))));
53+
(let headers =
54+
Http.(
55+
Header.add_transfer_encoding (Header.init ()) Transfer.Chunked)
56+
in
57+
( Http.Response.make ~headers (),
58+
fun _ic oc -> Lwt_io.write oc "8\r\nexpert 1\r\n0\r\n\r\n" ))));
5959
(fun _ _ ->
6060
Lwt.return
6161
(`Expert
62-
( (* Alternatively, cohttp.response.make injects the Chunked encoding when no
62+
( (* Alternatively, cohttp.response.make injects the Chunked encoding when no
6363
encoding is already in the headers. *)
64-
Cohttp.Response.make (),
65-
fun ic oc ->
66-
Lwt_io.write oc "8\r\nexpert 2\r\n0\r\n\r\n" >>= fun () ->
67-
Lwt_io.flush oc >>= fun () ->
68-
Cohttp_lwt_unix.Private.Input_channel.close ic )));
64+
Cohttp.Response.make (),
65+
fun ic oc ->
66+
Lwt_io.write oc "8\r\nexpert 2\r\n0\r\n\r\n" >>= fun () ->
67+
Lwt_io.flush oc >>= fun () ->
68+
Cohttp_lwt_unix.Private.Input_channel.close ic )));
6969
]
7070
|> response_sequence
7171

cohttp-lwt/src/s.ml

+10-11
Original file line numberDiff line numberDiff line change
@@ -94,15 +94,14 @@ type call =
9494
module can be used to consume [response_body]. Use {!Body.drain_body} if
9595
you don't consume the body by other means.
9696
97-
Leaks are detected by the GC and logged as debug messages, these can be
98-
enabled activating the debug logging. For example, this can be done as
99-
follows in
100-
[cohttp-lwt-unix]
97+
Leaks are detected by the GC and logged as debug messages, these can be
98+
enabled activating the debug logging. For example, this can be done as
99+
follows in [cohttp-lwt-unix]
101100
102-
{[
103-
Cohttp_lwt_unix.Debug.activate_debug ();
104-
Logs.set_level (Some Logs.Warning)
105-
]}
101+
{[
102+
Cohttp_lwt_unix.Debug.activate_debug ();
103+
Logs.set_level (Some Logs.Warning)
104+
]}
106105
107106
@raise {!Connection.Retry}
108107
on recoverable errors like the remote endpoint closing the connection
@@ -199,9 +198,9 @@ module type Client = sig
199198
{!val:Connection_cache.Make_no_cache.create} is used to resolve uri and
200199
create a dedicated connection with [ctx].
201200
202-
In most cases you should use the more specific helper calls in the
203-
interface rather than invoke this function directly. See {!head}, {!get}
204-
and {!post} for some examples. *)
201+
In most cases you should use the more specific helper calls in the
202+
interface rather than invoke this function directly. See {!head}, {!get}
203+
and {!post} for some examples. *)
205204
include
206205
Cohttp.Generic.Client.S
207206
with type 'a io = 'a Lwt.t

cohttp-server-lwt-unix/src/cohttp_server_lwt_unix.ml

+5-5
Original file line numberDiff line numberDiff line change
@@ -205,11 +205,11 @@ module Context = struct
205205
Int64.of_string_opt ("0x" ^ hex)
206206

207207
let step_chunked :
208-
'a.
209-
t ->
210-
f:(Body.Substring.t -> 'acc -> 'acc Lwt.t) ->
211-
init:'acc ->
212-
'acc option Lwt.t =
208+
'a.
209+
t ->
210+
f:(Body.Substring.t -> 'acc -> 'acc Lwt.t) ->
211+
init:'acc ->
212+
'acc option Lwt.t =
213213
fun t ~f ~init ->
214214
Input_channel.read_line_opt t.ic >>= function
215215
| None -> Lwt.return_none (* TODO invalid input *)

cohttp-server-lwt-unix/src/cohttp_server_lwt_unix.mli

+2-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,8 @@ module Body : sig
6161
(** [stream ?encoding f] respond with body generated by repeatedly applying
6262
[f]. When [f] returns [None], it will be considered terminated.
6363
64-
[?encoding] is the encoding to use. By default this is [Encoding.chunked]. *)
64+
[?encoding] is the encoding to use. By default this is [Encoding.chunked].
65+
*)
6566
end
6667

6768
module Context : sig

cohttp/src/accept.mli

+2-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,8 @@ type encoding = Accept_types.encoding =
5050
(** Basic language range tag. ["en-gb"] is represented as
5151
[Language ["en"; "gb"]].
5252
53-
@see <https://tools.ietf.org/html/rfc7231#section-5.3.5> the specification. *)
53+
@see <https://tools.ietf.org/html/rfc7231#section-5.3.5> the specification.
54+
*)
5455
type language = Accept_types.language = Language of string list | AnyLanguage
5556
[@@deriving sexp]
5657

cohttp/src/code.mli

+2-1
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,8 @@ val reason_phrase_of_code : int -> string
171171
(** Give a description of the given int code. *)
172172

173173
val is_informational : int -> bool
174-
(** Is the given int code belong to the class of "informational" return code ? *)
174+
(** Is the given int code belong to the class of "informational" return code ?
175+
*)
175176

176177
val is_success : int -> bool
177178
(** Is the given int code belong to the class of "success" return code ? *)

cohttp/src/header.mli

+8-4
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@ val to_list : t -> (string * string) list
4040
(** [to_list h] converts HTTP headers [h] to a list. Order and case is
4141
preserved.
4242
43-
{e Invariant (with case insensitive comparison):} [to_list (of_list l) = l] *)
43+
{e Invariant (with case insensitive comparison):} [to_list (of_list l) = l]
44+
*)
4445

4546
val init_with : string -> string -> t
4647
(** [init_with k v] construct a fresh HTTP headers with a single header with
@@ -118,7 +119,8 @@ val get_multi_concat : ?list_value_only:bool -> t -> string -> string option
118119
the last value paired with [k] in [h].
119120
120121
{e Invariant:}
121-
[forall h, k not a list-value header. get_multi_concat ~list-value-only:true h k = get h k] *)
122+
[forall h, k not a list-value header. get_multi_concat ~list-value-only:true
123+
h k = get h k] *)
122124

123125
val update : t -> string -> (string option -> string option) -> t
124126
(** [update h k f] returns an header list containing the same headers as [h],
@@ -190,7 +192,8 @@ val clean_dup : t -> t
190192
191193
Finally, following
192194
{{:https://tools.ietf.org/html/rfc7230#section-3.2.2} RFC7230§3.2.2}, the
193-
header [Set-cookie] is treated as an exception and ignored by [clean_dup]. *)
195+
header [Set-cookie] is treated as an exception and ignored by [clean_dup].
196+
*)
194197

195198
val get_content_range : t -> Int64.t option
196199
val get_media_type : t -> string option
@@ -213,7 +216,8 @@ val add_links : t -> Link.t list -> t
213216
val get_links : t -> Link.t list
214217

215218
val user_agent : string
216-
(** The User-Agent header used by this library, including the version of cohttp. *)
219+
(** The User-Agent header used by this library, including the version of cohttp.
220+
*)
217221

218222
val prepend_user_agent : t -> string -> t
219223
(** Prepend [user_agent] to the product token already declared in the

cohttp/src/request.ml

+3-1
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,9 @@ let uri { resource; headers; meth; _ } =
131131
| Some _ -> (
132132
Uri.(
133133
(* we have an absoluteURI *)
134-
match path uri with "" -> with_path uri "/" | _ -> uri))
134+
match path uri with
135+
| "" -> with_path uri "/"
136+
| _ -> uri))
135137
| None -> (
136138
let empty = Uri.of_string "" in
137139
let empty_base = Uri.of_string "///" in

cohttp/test/test_accept.ml

+4-6
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,14 @@
1616

1717
module A = Cohttp.Accept
1818

19-
let suite_of :
20-
type a.
19+
let suite_of : type a.
2120
(string option -> a) -> a Alcotest.testable -> (string * a) list -> _ list =
2221
fun pf t ->
2322
List.map (fun (s, expected) ->
2423
let test () = Alcotest.check t s (pf (Some s)) expected in
2524
(s, `Quick, test))
2625

27-
let suite_of_fail :
28-
type a.
26+
let suite_of_fail : type a.
2927
(string option -> a) -> a Alcotest.testable -> (string * exn) list -> _ list
3028
=
3129
fun pf _ ->
@@ -41,8 +39,8 @@ let suite_to_string_of : type a. (a -> string) -> (a * string) list -> _ list =
4139
let test () = Alcotest.(check string expected_str expected_str (pf v)) in
4240
(expected_str, `Quick, test))
4341

44-
let suite_to_string_of_fail :
45-
type a. (a -> string) -> (a * string * exn) list -> _ list =
42+
let suite_to_string_of_fail : type a.
43+
(a -> string) -> (a * string * exn) list -> _ list =
4644
fun pf ->
4745
List.map (fun (v, descr, e) ->
4846
let test () = Alcotest.(check_raises descr e (fun () -> ignore (pf v))) in

http/src/http.mli

+4-2
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,8 @@ module Header : sig
278278
returned value is the last value paired with [k] in [h].
279279
280280
{e Invariant:}
281-
[forall h, k not a list-value header. get_multi_concat ~list-value-only:true h k = get h k] *)
281+
[forall h, k not a list-value header. get_multi_concat
282+
~list-value-only:true h k = get h k] *)
282283

283284
val update : t -> string -> (string option -> string option) -> t
284285
(** [update h k f] returns an header list containing the same headers as [h],
@@ -357,7 +358,8 @@ module Header : sig
357358
358359
Finally, following
359360
{{:https://tools.ietf.org/html/rfc7230#section-3.2.2} RFC7230§3.2.2}, the
360-
header [Set-cookie] is treated as an exception and ignored by [clean_dup]. *)
361+
header [Set-cookie] is treated as an exception and ignored by [clean_dup].
362+
*)
361363

362364
val get_content_range : t -> Int64.t option
363365
val get_connection_close : t -> bool

0 commit comments

Comments
 (0)