diff --git a/.github/workflows/workflow.yml b/.github/workflows/workflow.yml index 92eacc98d5..f14cf8be5b 100644 --- a/.github/workflows/workflow.yml +++ b/.github/workflows/workflow.yml @@ -28,11 +28,13 @@ jobs: - ocaml-variants.4.11.2+afl - ocaml-variants.4.12.1+options,ocaml-option-afl - ocaml-variants.4.13.1+options,ocaml-option-afl - - ocaml-variants.4.14.0+options,ocaml-option-afl local-packages: - | *.opam !cohttp-eio.opam + !cohttp-curl-async.opam + !cohttp-async.opam + !cohttp-bench.opam runs-on: ${{ matrix.os }} @@ -40,6 +42,48 @@ jobs: - name: Checkout code uses: actions/checkout@v3 + - name: Use OCaml ${{ matrix.ocaml-compiler }} + uses: ocaml/setup-ocaml@v2 + with: + ocaml-compiler: ${{ matrix.ocaml-compiler }} + dune-cache: ${{ matrix.os == 'ubuntu-latest' }} + opam-depext: true + opam-depext-flags: --with-test + opam-local-packages: ${{ matrix.local-packages }} + + - run: | + sudo apt update + sudo apt upgrade + opam depext conf-libcurl + if: ${{ matrix.os == 'ubuntu-latest' }} + + - run: echo "PKG_CONFIG_PATH=$(brew --prefix openssl)/lib/pkgconfig" >>"$GITHUB_ENV" + if: ${{ matrix.os == 'macos-latest' }} + + - run: opam install --with-test --deps-only http cohttp cohttp-lwt cohttp-lwt-unix cohttp-server-lwt-unix cohttp-mirage cohttp-curl-lwt cohttp-curl cohttp-top + - run: opam exec -- dune build http cohttp cohttp-lwt cohttp-lwt-unix cohttp-server-lwt-unix cohttp-mirage cohttp-curl-lwt cohttp-curl cohttp-top + - run: opam exec -- dune runtest http cohttp cohttp-lwt cohttp-lwt-unix cohttp-server-lwt-unix cohttp-mirage cohttp-curl-lwt cohttp-curl cohttp-top + + build-test-cohttp-async: + if: github.event.pull_request.draft == false + strategy: + fail-fast: false + matrix: + os: + - ubuntu-latest + - macos-latest + ocaml-compiler: + - ocaml-variants.4.14.1+options,ocaml-option-afl + local-packages: + - | + *.opam + !cohttp-eio.opam + + runs-on: ${{ matrix.os }} + + steps: + - name: Checkout code + uses: actions/checkout@v3 - name: Use OCaml ${{ matrix.ocaml-compiler }} uses: ocaml/setup-ocaml@v2 @@ -59,9 +103,9 @@ jobs: - run: echo "PKG_CONFIG_PATH=$(brew --prefix openssl)/lib/pkgconfig" >>"$GITHUB_ENV" if: ${{ matrix.os == 'macos-latest' }} - - run: opam install --with-test --deps-only http cohttp cohttp-lwt cohttp-lwt-unix cohttp-server-lwt-unix cohttp-mirage cohttp-async cohttp-curl-async cohttp-curl-lwt cohttp-curl cohttp-top cohttp-bench - - run: opam exec -- dune build http cohttp cohttp-lwt cohttp-lwt-unix cohttp-server-lwt-unix cohttp-mirage cohttp-async cohttp-curl-async cohttp-curl-lwt cohttp-curl cohttp-top cohttp-bench - - run: opam exec -- dune runtest http cohttp cohttp-lwt cohttp-lwt-unix cohttp-server-lwt-unix cohttp-mirage cohttp-async cohttp-curl-async cohttp-curl-lwt cohttp-curl cohttp-top cohttp-bench + - run: opam install --with-test --deps-only http cohttp cohttp-lwt cohttp-lwt-unix cohttp-server-lwt-unix cohttp-async cohttp-curl-async cohttp-mirage cohttp-curl-lwt cohttp-curl cohttp-top cohttp-bench + - run: opam exec -- dune build http cohttp cohttp-lwt cohttp-lwt-unix cohttp-server-lwt-unix cohttp-async cohttp-curl-async cohttp-mirage cohttp-curl-lwt cohttp-curl cohttp-top cohttp-bench + - run: opam exec -- dune runtest http cohttp cohttp-lwt cohttp-lwt-unix cohttp-server-lwt-unix cohttp-async cohttp-curl-async cohttp-mirage cohttp-curl-lwt cohttp-curl cohttp-top cohttp-bench build-test-cohttp-eio: if: github.event.pull_request.draft == false @@ -95,7 +139,5 @@ jobs: alpha: https://github.com/kit-ty-kate/opam-alpha-repository.git - run: opam install --with-test --deps-only cohttp-eio - - run: opam exec -- dune build cohttp-eio - - run: opam exec -- dune runtest cohttp-eio diff --git a/CHANGES.md b/CHANGES.md index 42d845566f..53c94d4e7a 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,10 +1,7 @@ ## Unreleased - -- cohttp-lwt server: call conn_closed before drainig the body of response on error (pirbo) -- cohttp-eio: Relax socket interface requirement on `Server.connection_handler`. - -## v6.0.0~alpha1 (2023-04-28) - +- cohttp-async, cohttp-curl-async: compatibility with core/async v0.16.0 (mseri, dkalinichenko-js #976) +- cohttp-lwt server: call conn_closed before drainig the body of response on error (pirbo #982) +- cohttp-eio: Relax socket interface requirement on `Server.connection_handler`. (mefyl #983) - cohttp,cohttp-async server: correctly close broken streams (reported by Stéphane Glondu, fix by samhot and anuragsoni) - cohttp-eio: remove unused code from tests to work with Eio 0.8 (talex5 #967) - Upgrade dune to v3.0 (bikallem #947) diff --git a/cohttp-async.opam b/cohttp-async.opam index 349faf3a79..228d3959ba 100644 --- a/cohttp-async.opam +++ b/cohttp-async.opam @@ -25,13 +25,13 @@ doc: "https://mirage.github.io/ocaml-cohttp/" bug-reports: "https://github.com/mirage/ocaml-cohttp/issues" depends: [ "dune" {>= "3.0"} - "ocaml" {>= "4.08"} + "ocaml" {>= "4.14"} "http" {= version} "cohttp" {= version} - "async_kernel" {>= "v0.14.0"} - "async_unix" {>= "v0.14.0"} - "async" {>= "v0.14.0"} - "base" {>= "v0.11.0"} + "async_kernel" {>= "v0.16.0"} + "async_unix" {>= "v0.16.0"} + "async" {>= "v0.16.0"} + "base" {>= "v0.16"} "core" {with-test} "core_unix" {>= "v0.14.0"} "conduit-async" {>= "1.2.0"} diff --git a/cohttp-async/bin/cohttp_server_async.ml b/cohttp-async/bin/cohttp_server_async.ml index 6de184c4e0..8398e02725 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/examples/hello_world.ml b/cohttp-async/examples/hello_world.ml index e3639ce91f..9005012aa0 100644 --- a/cohttp-async/examples/hello_world.ml +++ b/cohttp-async/examples/hello_world.ml @@ -18,8 +18,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; Server.create ~on_handler_error:`Raise (Async.Tcp.Where_to_listen.of_port port) handler diff --git a/cohttp-async/examples/receive_post.ml b/cohttp-async/examples/receive_post.ml index 257318a612..88636b06fe 100644 --- a/cohttp-async/examples/receive_post.ml +++ b/cohttp-async/examples/receive_post.ml @@ -7,15 +7,15 @@ module Server = Cohttp_async.Server (* 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 |> Http.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 () diff --git a/cohttp-async/src/body.ml b/cohttp-async/src/body.ml index dc31b523f9..5d430648ab 100644 --- a/cohttp-async/src/body.ml +++ b/cohttp-async/src/body.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 0ad18074e9..c9535416da 100644 --- a/cohttp-async/src/client.ml +++ b/cohttp-async/src/client.ml @@ -120,7 +120,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 36a151e106..60769ead1e 100644 --- a/cohttp-async/src/io.ml +++ b/cohttp-async/src/io.ml @@ -20,7 +20,7 @@ open Async_kernel module IO = struct 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" @@ -44,7 +44,7 @@ module IO = struct k () in msgf @@ fun ?header:_ ?tags:_ fmt -> - Format.kfprintf k fmtr Caml.("@[" ^^ fmt ^^ "@]@.") + Format.kfprintf k fmtr Stdlib.("@[" ^^ fmt ^^ "@]@.") in { Logs.report } @@ -58,11 +58,11 @@ module IO = struct 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 78f38b0249..d709759f0e 100644 --- a/cohttp-async/test/test_async_integration.ml +++ b/cohttp-async/test/test_async_integration.ml @@ -81,7 +81,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) @@ -113,7 +113,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-bench/async_server.ml b/cohttp-bench/async_server.ml index d662bdb86b..632e731271 100644 --- a/cohttp-bench/async_server.ml +++ b/cohttp-bench/async_server.ml @@ -13,7 +13,7 @@ let start_server port () = handler >>= fun server -> Deferred.forever () (fun () -> - after Time.Span.(of_sec 0.5) >>| fun () -> + after Time_float.Span.(of_sec 0.5) >>| fun () -> Log.Global.printf "Active connections: %d" (Server.num_connections server)); Deferred.never () diff --git a/cohttp-curl-async.opam b/cohttp-curl-async.opam index 1a8dbd2203..93b977010b 100644 --- a/cohttp-curl-async.opam +++ b/cohttp-curl-async.opam @@ -25,7 +25,7 @@ depends: [ "http" {= version} "stringext" "cohttp-curl" {= version} - "core" + "core" {>= "v0.16.0"} "core_unix" {>= "v0.14.0"} "async_kernel" "async_unix" diff --git a/cohttp-curl-async/bin/curl.ml b/cohttp-curl-async/bin/curl.ml index b1d532fd70..517b6d7ca3 100644 --- a/cohttp-curl-async/bin/curl.ml +++ b/cohttp-curl-async/bin/curl.ml @@ -3,7 +3,7 @@ module Curl = Cohttp_curl_async module Sexp = Sexplib0.Sexp open Async_kernel module Writer = Async_unix.Writer -module Time = Core.Time +module Time = Core.Time_float let ( let* ) x f = Deferred.bind x ~f diff --git a/cohttp-curl-async/src/cohttp_curl_async.ml b/cohttp-curl-async/src/cohttp_curl_async.ml index 7a47d611c4..e955047cd4 100644 --- a/cohttp-curl-async/src/cohttp_curl_async.ml +++ b/cohttp-curl-async/src/cohttp_curl_async.ml @@ -1,5 +1,5 @@ open Async_kernel -module Time = Core.Time +module Time = Core.Time_float module Fd = Async_unix.Fd module Clock = Async_unix.Clock @@ -164,7 +164,7 @@ module Request = struct let base = let timeout_ms = Option.map - (fun timeout -> Core.Time.Span.to_ms timeout |> int_of_float) + (fun timeout -> Time.Span.to_ms timeout |> int_of_float) timeout in Cohttp_curl.Request.create ?timeout_ms ?headers method_ ~uri ~input diff --git a/cohttp-curl-async/src/cohttp_curl_async.mli b/cohttp-curl-async/src/cohttp_curl_async.mli index ab9fc496f1..274e9d6cc7 100644 --- a/cohttp-curl-async/src/cohttp_curl_async.mli +++ b/cohttp-curl-async/src/cohttp_curl_async.mli @@ -51,7 +51,7 @@ module Request : sig handled. *) val create : - ?timeout:Core.Time.Span.t (** timeout for the request *) -> + ?timeout:Core.Time_float.Span.t (** timeout for the request *) -> ?headers:Http.Header.t (** http headers *) -> Http.Method.t (** http method *) -> uri:string (** uri *) -> diff --git a/dune-project b/dune-project index 948b48a3b1..b57c16067c 100644 --- a/dune-project +++ b/dune-project @@ -174,13 +174,13 @@ should also be fine under Windows too. (cohttp (= :version)) (async_kernel - (>= v0.14.0)) + (>= v0.16.0)) (async_unix - (>= v0.14.0)) + (>= v0.16.0)) (async - (>= v0.14.0)) + (>= v0.16.0)) (base - (>= v0.11.0)) + (>= v0.16.0)) (core :with-test) (core_unix (>= v0.14.0)) @@ -317,7 +317,7 @@ should also be fine under Windows too. stringext (cohttp-curl (= :version)) - core + (core (>= v0.16.0)) (core_unix (>= v0.14.0)) async_kernel async_unix