From 6307f9b2b18274916f74391f7bbd901d527b5348 Mon Sep 17 00:00:00 2001 From: Stephane Glondu Date: Sun, 8 Oct 2023 20:42:21 +0200 Subject: [PATCH] New upstream version 5.3.0 --- .github/workflows/workflow.yml | 6 +----- CHANGES.md | 4 ++++ cohttp-async.opam | 16 ++++++++-------- cohttp-async/bin/cohttp_server_async.ml | 2 +- cohttp-async/src/body_raw.ml | 2 +- cohttp-async/src/client.ml | 2 +- cohttp-async/src/io.ml | 8 ++++---- cohttp-async/test/test_async_integration.ml | 4 ++-- cohttp-lwt-jsoo.opam | 2 +- cohttp-lwt-unix.opam | 2 +- cohttp-lwt.opam | 2 +- cohttp-mirage.opam | 2 +- cohttp-mirage/src/client.ml | 2 +- cohttp-mirage/src/io.ml | 2 +- cohttp-mirage/src/io.mli | 2 +- cohttp-mirage/src/static.ml | 2 +- cohttp-mirage/src/static.mli | 2 +- cohttp-top.opam | 2 +- cohttp.opam | 2 +- cohttp/scripts/generate.ml | 2 +- dune-project | 2 +- examples/async/dune | 4 ++-- examples/async/hello_world.ml | 6 +++--- examples/async/receive_post.ml | 8 ++++---- examples/async/s3_cp.ml | 4 +++- 25 files changed, 47 insertions(+), 45 deletions(-) diff --git a/.github/workflows/workflow.yml b/.github/workflows/workflow.yml index c6b46eb..b906de0 100644 --- a/.github/workflows/workflow.yml +++ b/.github/workflows/workflow.yml @@ -16,11 +16,7 @@ jobs: - macos-latest - ubuntu-latest ocaml-compiler: - - 4.08.x - - 4.09.x - - 4.10.x - - 4.11.x - - 4.12.x + - 4.14.x runs-on: ${{ matrix.os }} diff --git a/CHANGES.md b/CHANGES.md index 0e604c5..1768901 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,3 +1,7 @@ +## v5.3.0 (2023-07-21) + +- cohttp-async: support for base/async v0.16 + ## v5.2.0 (2023-07-07) - cohttp-lwt server: call conn_closed before drainig the body of response on error (pirbo) diff --git a/cohttp-async.opam b/cohttp-async.opam index 18fc6ea..7a8d4c0 100644 --- a/cohttp-async.opam +++ b/cohttp-async.opam @@ -1,4 +1,4 @@ -version: "5.2.0" +version: "5.3.0" opam-version: "2.0" maintainer: "anil@recoil.org" authors: [ @@ -24,14 +24,14 @@ homepage: "https://github.com/mirage/ocaml-cohttp" doc: "https://mirage.github.io/ocaml-cohttp/" bug-reports: "https://github.com/mirage/ocaml-cohttp/issues" depends: [ - "ocaml" {>= "4.08"} + "ocaml" {>= "4.14"} "dune" {>= "2.0"} - "async_kernel" {>= "v0.14.0"} - "async_unix" {>= "v0.14.0"} - "async" {>= "v0.14.0" & < "v0.16.0"} - "base" {>= "v0.11.0"} - "core" {with-test & < "v0.15.0"} - "core_unix" {>= "v0.14.0"} + "async_kernel" {>= "v0.16.0"} + "async_unix" {>= "v0.16.0"} + "async" {>= "v0.16.0"} + "base" {>= "v0.16.0"} + "core" {with-test} + "core_unix" {>= "v0.16.0"} "cohttp" {= version} "conduit-async" {>= "1.2.0"} "magic-mime" diff --git a/cohttp-async/bin/cohttp_server_async.ml b/cohttp-async/bin/cohttp_server_async.ml index 10b3133..494b936 100644 --- a/cohttp-async/bin/cohttp_server_async.ml +++ b/cohttp-async/bin/cohttp_server_async.ml @@ -50,7 +50,7 @@ let serve ~info ~docroot ~index uri path = | `No | `Unknown -> (* Do a directory listing *) Sys.ls_dir file_name - >>= Deferred.List.map ~f:(fun f -> + >>= Deferred.List.map ~how:`Parallel ~f:(fun f -> let file_name = file_name / f in try_with (fun () -> Unix.stat file_name >>| fun stat -> diff --git a/cohttp-async/src/body_raw.ml b/cohttp-async/src/body_raw.ml index 60db20d..919b1cc 100644 --- a/cohttp-async/src/body_raw.ml +++ b/cohttp-async/src/body_raw.ml @@ -67,7 +67,7 @@ let write_body write_body (body : t) writer = match body with | `Empty -> return () | `String s -> write_body writer s - | `Strings sl -> Deferred.List.iter sl ~f:(write_body writer) + | `Strings sl -> Deferred.List.iter ~how:`Sequential sl ~f:(write_body writer) | `Pipe p -> Pipe.iter p ~f:(write_body writer) let pipe_of_body read_chunk ic = diff --git a/cohttp-async/src/client.ml b/cohttp-async/src/client.ml index f7e8d39..ba0089a 100644 --- a/cohttp-async/src/client.ml +++ b/cohttp-async/src/client.ml @@ -123,7 +123,7 @@ let callv ?interrupt ?ssl_config uri reqs = Connection.connect ?interrupt ?ssl_config uri >>| fun connection -> let responses = Pipe.map' ~max_queue_length:1 reqs ~f:(fun reqs -> - Deferred.Queue.map reqs ~f:(fun (req, body) -> + Deferred.Queue.map ~how:`Sequential reqs ~f:(fun (req, body) -> Connection.request ~body connection req)) in Pipe.closed responses diff --git a/cohttp-async/src/io.ml b/cohttp-async/src/io.ml index 9e11edb..cb0ad69 100644 --- a/cohttp-async/src/io.ml +++ b/cohttp-async/src/io.ml @@ -18,7 +18,7 @@ open Base open Async_kernel module Writer = Async_unix.Writer module Reader = Async_unix.Reader -module Format = Caml.Format +module Format = Stdlib.Format let log_src_name = "cohttp.async.io" let src = Logs.Src.create log_src_name ~doc:"Cohttp Async IO module" @@ -42,7 +42,7 @@ let default_reporter () = k () in msgf @@ fun ?header:_ ?tags:_ fmt -> - Format.kfprintf k fmtr Caml.("@[" ^^ fmt ^^ "@]@.") + Format.kfprintf k fmtr Stdlib.("@[" ^^ fmt ^^ "@]@.") in { Logs.report } @@ -56,11 +56,11 @@ let set_log = Logs.set_reporter (default_reporter ())) let check_debug norm_fn debug_fn = - match Caml.Sys.getenv "COHTTP_DEBUG" with + match Stdlib.Sys.getenv "COHTTP_DEBUG" with | _ -> Lazy.force set_log; debug_fn - | exception Caml.Not_found -> norm_fn + | exception Stdlib.Not_found -> norm_fn type 'a t = 'a Deferred.t diff --git a/cohttp-async/test/test_async_integration.ml b/cohttp-async/test/test_async_integration.ml index 5acc2a8..32a2a6a 100644 --- a/cohttp-async/test/test_async_integration.ml +++ b/cohttp-async/test/test_async_integration.ml @@ -79,7 +79,7 @@ let ts = reqs |> Pipe.of_list |> Client.callv uri >>= fun responses -> responses |> Pipe.to_list >>= fun resps -> resps - |> Deferred.List.iter ~f:(fun (_resp, body) -> + |> Deferred.List.iter ~how:`Sequential ~f:(fun (_resp, body) -> let expected_body = body_q |> Queue.dequeue_exn in body |> Body.to_string >>| fun body -> assert_equal ~printer expected_body body) @@ -111,7 +111,7 @@ let ts = ("Pipe with empty strings", Pipe.of_list [ ""; ""; "" ], true); ] in - Deferred.List.iter tests ~f:(fun (msg, pipe, expected) -> + Deferred.List.iter ~how:`Sequential tests ~f:(fun (msg, pipe, expected) -> is_empty (`Pipe pipe) >>| fun real -> assert_equal ~msg expected real) >>= fun () -> diff --git a/cohttp-lwt-jsoo.opam b/cohttp-lwt-jsoo.opam index dfb8f06..1af72ff 100644 --- a/cohttp-lwt-jsoo.opam +++ b/cohttp-lwt-jsoo.opam @@ -1,4 +1,4 @@ -version: "5.2.0" +version: "5.3.0" opam-version: "2.0" maintainer: "anil@recoil.org" authors: [ diff --git a/cohttp-lwt-unix.opam b/cohttp-lwt-unix.opam index fbcd809..7765875 100644 --- a/cohttp-lwt-unix.opam +++ b/cohttp-lwt-unix.opam @@ -1,4 +1,4 @@ -version: "5.2.0" +version: "5.3.0" opam-version: "2.0" maintainer: "anil@recoil.org" authors: [ diff --git a/cohttp-lwt.opam b/cohttp-lwt.opam index a88bfcc..cbfd435 100644 --- a/cohttp-lwt.opam +++ b/cohttp-lwt.opam @@ -1,4 +1,4 @@ -version: "5.2.0" +version: "5.3.0" opam-version: "2.0" maintainer: "anil@recoil.org" authors: [ diff --git a/cohttp-mirage.opam b/cohttp-mirage.opam index d767aa5..61186f6 100644 --- a/cohttp-mirage.opam +++ b/cohttp-mirage.opam @@ -1,4 +1,4 @@ -version: "5.2.0" +version: "5.3.0" opam-version: "2.0" maintainer: "anil@recoil.org" authors: ["Anil Madhavapeddy" "Thomas Gazagnaire"] diff --git a/cohttp-mirage/src/client.ml b/cohttp-mirage/src/client.ml index b34ebfd..a2de582 100644 --- a/cohttp-mirage/src/client.ml +++ b/cohttp-mirage/src/client.ml @@ -14,7 +14,7 @@ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * - * cohttp v5.2.0 + * cohttp v5.3.0 *) open Lwt.Infix diff --git a/cohttp-mirage/src/io.ml b/cohttp-mirage/src/io.ml index 84b5466..301c634 100644 --- a/cohttp-mirage/src/io.ml +++ b/cohttp-mirage/src/io.ml @@ -14,7 +14,7 @@ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * - * cohttp v5.2.0 + * cohttp v5.3.0 *) open Lwt.Infix diff --git a/cohttp-mirage/src/io.mli b/cohttp-mirage/src/io.mli index 10c8710..1768bbe 100644 --- a/cohttp-mirage/src/io.mli +++ b/cohttp-mirage/src/io.mli @@ -14,7 +14,7 @@ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * - * cohttp v5.2.0 + * cohttp v5.3.0 *) (** Cohttp IO implementation using Mirage channels. *) diff --git a/cohttp-mirage/src/static.ml b/cohttp-mirage/src/static.ml index bba69cf..99e8aa3 100644 --- a/cohttp-mirage/src/static.ml +++ b/cohttp-mirage/src/static.ml @@ -14,7 +14,7 @@ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * - * cohttp v5.2.0 + * cohttp v5.3.0 *) module Key = Mirage_kv.Key diff --git a/cohttp-mirage/src/static.mli b/cohttp-mirage/src/static.mli index 9ee4763..b9e9545 100644 --- a/cohttp-mirage/src/static.mli +++ b/cohttp-mirage/src/static.mli @@ -14,7 +14,7 @@ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * - * cohttp v5.2.0 + * cohttp v5.3.0 *) (** Serve static HTTP sites from a Mirage key-value store. *) diff --git a/cohttp-top.opam b/cohttp-top.opam index d4b5b2e..bad206e 100644 --- a/cohttp-top.opam +++ b/cohttp-top.opam @@ -1,4 +1,4 @@ -version: "5.2.0" +version: "5.3.0" opam-version: "2.0" maintainer: "anil@recoil.org" authors: [ diff --git a/cohttp.opam b/cohttp.opam index 7e73c55..54c0733 100644 --- a/cohttp.opam +++ b/cohttp.opam @@ -1,4 +1,4 @@ -version: "5.2.0" +version: "5.3.0" opam-version: "2.0" maintainer: "anil@recoil.org" authors: [ diff --git a/cohttp/scripts/generate.ml b/cohttp/scripts/generate.ml index 3dbf6ba..160e990 100644 --- a/cohttp/scripts/generate.ml +++ b/cohttp/scripts/generate.ml @@ -94,7 +94,7 @@ let output t = Buffer.contents buf let parse_error fmt = - Printf.kprintf + Printf.ksprintf (fun msg -> Printf.eprintf "parse error: %s\n" msg; exit 1) diff --git a/dune-project b/dune-project index c3014fe..b7266ed 100644 --- a/dune-project +++ b/dune-project @@ -1,3 +1,3 @@ (lang dune 2.0) (name cohttp) -(version v5.2.0) +(version v5.3.0) diff --git a/examples/async/dune b/examples/async/dune index 92af226..8d875dd 100644 --- a/examples/async/dune +++ b/examples/async/dune @@ -1,6 +1,6 @@ (executables - (names hello_world receive_post) - (libraries mirage-crypto cohttp-async base async_kernel)) + (names hello_world receive_post s3_cp) + (libraries mirage-crypto cohttp-async base async_kernel core_unix.command_unix)) (alias (name runtest) diff --git a/examples/async/hello_world.ml b/examples/async/hello_world.ml index e6a620e..1af93cf 100644 --- a/examples/async/hello_world.ml +++ b/examples/async/hello_world.ml @@ -19,8 +19,8 @@ let handler ~body:_ _sock req = | _ -> Server.respond_string ~status:`Not_found "Route not found" let start_server port () = - Caml.Printf.eprintf "Listening for HTTP on port %d\n" port; - Caml.Printf.eprintf "Try 'curl http://localhost:%d/test?hello=xyz'\n%!" port; + Stdlib.Printf.eprintf "Listening for HTTP on port %d\n" port; + Stdlib.Printf.eprintf "Try 'curl http://localhost:%d/test?hello=xyz'\n%!" port; Cohttp_async.Server.create ~on_handler_error:`Raise (Async.Tcp.Where_to_listen.of_port port) handler @@ -35,4 +35,4 @@ let () = (optional_with_default 8080 int) ~doc:"int Source port to listen on") start_server - |> Command.run + |> Command_unix.run diff --git a/examples/async/receive_post.ml b/examples/async/receive_post.ml index cf0830c..34ea2c1 100644 --- a/examples/async/receive_post.ml +++ b/examples/async/receive_post.ml @@ -6,15 +6,15 @@ open Cohttp_async (* compile with: $ corebuild receive_post.native -pkg cohttp.async *) let start_server port () = - Caml.Printf.eprintf "Listening for HTTP on port %d\n" port; - Caml.Printf.eprintf "Try 'curl -X POST -d 'foo bar' http://localhost:%d\n" + Stdlib.Printf.eprintf "Listening for HTTP on port %d\n" port; + Stdlib.Printf.eprintf "Try 'curl -X POST -d 'foo bar' http://localhost:%d\n" port; Cohttp_async.Server.create ~on_handler_error:`Raise (Async.Tcp.Where_to_listen.of_port port) (fun ~body _ req -> match req |> Cohttp.Request.meth with | `POST -> Body.to_string body >>= fun body -> - Caml.Printf.eprintf "Body: %s" body; + Stdlib.Printf.eprintf "Body: %s" body; Server.respond `OK | _ -> Server.respond `Method_not_allowed) >>= fun _ -> Deferred.never () @@ -28,4 +28,4 @@ let () = (optional_with_default 8080 int) ~doc:"int Source port to listen on") start_server - |> Command.run + |> Command_unix.run diff --git a/examples/async/s3_cp.ml b/examples/async/s3_cp.ml index 65022d3..48a6f64 100644 --- a/examples/async/s3_cp.ml +++ b/examples/async/s3_cp.ml @@ -45,6 +45,8 @@ open Async open Cohttp open Cohttp_async +module Time = Time_float + let ksrt (k, _) (k', _) = String.compare k k' module Compat = struct @@ -400,4 +402,4 @@ let () = +> anon ("src" %: string) +> anon ("dst" %: string)) main - |> run + |> Command_unix.run -- 2.39.5