From: Stephane Glondu Date: Sun, 8 Oct 2023 18:42:15 +0000 (+0200) Subject: New upstream version 5.2.0 X-Git-Tag: archive/raspbian/6.2.2-1+rpi1^2~5^2~8 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=93b2313f5de3ef52c74c9901d3fcbcd98d396274;p=ocaml-cohttp.git New upstream version 5.2.0 --- diff --git a/CHANGES.md b/CHANGES.md index 0a4aa0f..0e604c5 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,3 +1,7 @@ +## v5.2.0 (2023-07-07) + +- cohttp-lwt server: call conn_closed before drainig the body of response on error (pirbo) + ## v5.1.0 (2023-04-04) - cohttp,cohttp-async server: correctly close broken streams (reported by Stéphane Glondu, fix by samhot and anuragsoni) @@ -35,10 +39,10 @@ + ```clean_dup``` enables the user to clean headers that follows the {{:https://tools.ietf.org/html/rfc7230#section-3.2.2} RFC7230§3.2.2} (no duplicate, except ```set-cookie```) + ```get_multi_concat``` has been added to get a result similar to the previous ```get``` function. -- Cohttp.Header: performance improvement (mseri, anuragsoni #778) +- Cohttp.Header: performance improvement (mseri, anuragsoni #778) **Breaking** the headers are no-longer lowercased when parsed, the headers key comparison is case insensitive instead. -- cohttp-lwt-unix: Adopt ocaml-conduit 5.0.0 (smorimoto #787) +- cohttp-lwt-unix: Adopt ocaml-conduit 5.0.0 (smorimoto #787) **Breaking** `Conduit_lwt_unix.connect`'s `ctx` param type chaged from `ctx` to `ctx Lazy.t` - cohttp-mirage: fix deprecated fmt usage (tmcgilchrist #783) diff --git a/cohttp-async.opam b/cohttp-async.opam index 594f636..18fc6ea 100644 --- a/cohttp-async.opam +++ b/cohttp-async.opam @@ -1,3 +1,4 @@ +version: "5.2.0" opam-version: "2.0" maintainer: "anil@recoil.org" authors: [ @@ -27,9 +28,9 @@ depends: [ "dune" {>= "2.0"} "async_kernel" {>= "v0.14.0"} "async_unix" {>= "v0.14.0"} - "async" {>= "v0.14.0"} + "async" {>= "v0.14.0" & < "v0.16.0"} "base" {>= "v0.11.0"} - "core" {with-test} + "core" {with-test & < "v0.15.0"} "core_unix" {>= "v0.14.0"} "cohttp" {= version} "conduit-async" {>= "1.2.0"} @@ -50,4 +51,4 @@ build: [ ["dune" "runtest" "-p" name "-j" jobs] {with-test} ] available: arch != "s390x" -dev-repo: "git+https://github.com/mirage/ocaml-cohttp.git" +dev-repo: "git+https://github.com/mirage/ocaml-cohttp.git" \ No newline at end of file diff --git a/cohttp-lwt-jsoo.opam b/cohttp-lwt-jsoo.opam index 24c7fbd..dfb8f06 100644 --- a/cohttp-lwt-jsoo.opam +++ b/cohttp-lwt-jsoo.opam @@ -1,3 +1,4 @@ +version: "5.2.0" opam-version: "2.0" maintainer: "anil@recoil.org" authors: [ @@ -39,4 +40,4 @@ build: [ ["dune" "build" "-p" name "-j" jobs] ["dune" "runtest" "-p" name "-j" jobs] {with-test} ] -dev-repo: "git+https://github.com/mirage/ocaml-cohttp.git" +dev-repo: "git+https://github.com/mirage/ocaml-cohttp.git" \ No newline at end of file diff --git a/cohttp-lwt-unix.opam b/cohttp-lwt-unix.opam index 9bf319c..fbcd809 100644 --- a/cohttp-lwt-unix.opam +++ b/cohttp-lwt-unix.opam @@ -1,3 +1,4 @@ +version: "5.2.0" opam-version: "2.0" maintainer: "anil@recoil.org" authors: [ @@ -29,7 +30,7 @@ depends: [ "dune" {>= "2.0"} "conduit-lwt" {>= "5.0.0"} "conduit-lwt-unix" {>= "5.0.0"} - "cmdliner" + "cmdliner" {>= "1.1.0"} "magic-mime" "logs" "fmt" {>= "0.8.2"} @@ -44,4 +45,4 @@ build: [ ["dune" "build" "-p" name "-j" jobs] ["dune" "runtest" "-p" name "-j" jobs] {with-test} ] -dev-repo: "git+https://github.com/mirage/ocaml-cohttp.git" +dev-repo: "git+https://github.com/mirage/ocaml-cohttp.git" \ No newline at end of file diff --git a/cohttp-lwt-unix/bin/cohttp_curl_lwt.ml b/cohttp-lwt-unix/bin/cohttp_curl_lwt.ml index c31dafe..4adc748 100644 --- a/cohttp-lwt-unix/bin/cohttp_curl_lwt.ml +++ b/cohttp-lwt-unix/bin/cohttp_curl_lwt.ml @@ -58,7 +58,7 @@ let run_client level ofile uri meth = open Cmdliner let uri = - let loc : Uri.t Arg.converter = + let loc : Uri.t Arg.conv = let parse s = try `Ok (Uri.of_string s) with Failure _ -> `Error "unable to parse URI" in @@ -81,25 +81,29 @@ let ofile = Arg.(value & opt (some string) None & info [ "o" ] ~docv:"FILE" ~doc) let cmd = - let doc = "retrieve a remote URI contents" in - let man = - [ - `S "DESCRIPTION"; - `P - "$(tname) fetches the remote $(i,URI) and prints it to standard \ - output. The output file can also be specified with the $(b,-o) \ - option, and more verbose debugging out obtained via the $(b,-v) \ - option."; - `S "BUGS"; - `P - "Report them via e-mail to , or \ - on the issue tracker at \ - "; - `S "SEE ALSO"; - `P "$(b,curl)(1), $(b,wget)(1)"; - ] + let info = + let version = Cohttp.Conf.version in + let doc = "retrieve a remote URI contents" in + let man = + [ + `S "DESCRIPTION"; + `P + "$(tname) fetches the remote $(i,URI) and prints it to standard \ + output. The output file can also be specified with the $(b,-o) \ + option, and more verbose debugging out obtained via the $(b,-v) \ + option."; + `S "BUGS"; + `P + "Report them via e-mail to , or \ + on the issue tracker at \ + "; + `S "SEE ALSO"; + `P "$(b,curl)(1), $(b,wget)(1)"; + ] + in + Cmd.info "cohttp-curl" ~version ~doc ~man in - ( Term.(pure run_client $ verb $ ofile $ uri $ meth), - Term.info "cohttp-curl" ~version:Cohttp.Conf.version ~doc ~man ) + let term = Term.(const run_client $ verb $ ofile $ uri $ meth) in + Cmd.v info term -let () = match Term.eval cmd with `Error _ -> exit 1 | _ -> exit 0 +let () = exit @@ Cmd.eval cmd diff --git a/cohttp-lwt-unix/bin/cohttp_proxy_lwt.ml b/cohttp-lwt-unix/bin/cohttp_proxy_lwt.ml index 9fddad8..1f69801 100644 --- a/cohttp-lwt-unix/bin/cohttp_proxy_lwt.ml +++ b/cohttp-lwt-unix/bin/cohttp_proxy_lwt.ml @@ -101,19 +101,25 @@ let ssl_key = Arg.(value & opt (some string) None & info [ "k" ] ~docv:"SSL_KEY" ~doc) let cmd = - let doc = "a simple http proxy" in - let man = - [ - `S "DESCRIPTION"; - `P "$(tname) sets up a simple http proxy with lwt as backend"; - `S "BUGS"; - `P - "Report them via e-mail to , or \ - on the issue tracker at \ - "; - ] + let info = + let version = Cohttp.Conf.version in + let doc = "a simple http proxy" in + let man = + [ + `S "DESCRIPTION"; + `P "$(tname) sets up a simple http proxy with lwt as backend"; + `S "BUGS"; + `P + "Report them via e-mail to , or \ + on the issue tracker at \ + "; + ] + in + Cmd.info "cohttp-proxy" ~version ~doc ~man in - ( Term.(pure lwt_start_proxy $ port $ host $ verb $ ssl_cert $ ssl_key), - Term.info "cohttp-proxy" ~version:Cohttp.Conf.version ~doc ~man ) + let term = + Term.(const lwt_start_proxy $ port $ host $ verb $ ssl_cert $ ssl_key) + in + Cmd.v info term -let () = match Term.eval cmd with `Error _ -> exit 1 | _ -> exit 0 +let () = exit @@ Cmd.eval cmd diff --git a/cohttp-lwt-unix/bin/cohttp_server_lwt.ml b/cohttp-lwt-unix/bin/cohttp_server_lwt.ml index b4c2b63..57b0f6d 100644 --- a/cohttp-lwt-unix/bin/cohttp_server_lwt.ml +++ b/cohttp-lwt-unix/bin/cohttp_server_lwt.ml @@ -163,19 +163,25 @@ let doc_root = Arg.(value & pos 0 dir "." & info [] ~docv:"DOCROOT" ~doc) let cmd = - let doc = "a simple http server" in - let man = - [ - `S "DESCRIPTION"; - `P "$(tname) sets up a simple http server with lwt as backend"; - `S "BUGS"; - `P - "Report them via e-mail to , or \ - on the issue tracker at \ - "; - ] + let info = + let version = Cohttp.Conf.version in + let doc = "a simple http server" in + let man = + [ + `S "DESCRIPTION"; + `P "$(tname) sets up a simple http server with lwt as backend"; + `S "BUGS"; + `P + "Report them via e-mail to , or \ + on the issue tracker at \ + "; + ] + in + Cmd.info "cohttp-server" ~version ~doc ~man + in + let term = + Term.(const lwt_start_server $ doc_root $ port $ host $ index $ verb $ tls) in - ( Term.(pure lwt_start_server $ doc_root $ port $ host $ index $ verb $ tls), - Term.info "cohttp-server" ~version:Cohttp.Conf.version ~doc ~man ) + Cmd.v info term -let () = match Term.eval cmd with `Error _ -> exit 1 | _ -> exit 0 +let () = exit @@ Cmd.eval cmd diff --git a/cohttp-lwt-unix/bin/dune b/cohttp-lwt-unix/bin/dune index 63e95e9..b8ae61a 100644 --- a/cohttp-lwt-unix/bin/dune +++ b/cohttp-lwt-unix/bin/dune @@ -1,6 +1,14 @@ (executables (names cohttp_curl_lwt cohttp_proxy_lwt cohttp_server_lwt) - (libraries cohttp-lwt-unix cohttp_server logs logs.lwt logs.fmt logs.cli - cmdliner conduit-lwt fmt.tty) + (libraries + cohttp-lwt-unix + cohttp_server + logs + logs.lwt + logs.fmt + logs.cli + cmdliner + conduit-lwt + fmt.tty) (package cohttp-lwt-unix) (public_names cohttp-curl-lwt cohttp-proxy-lwt cohttp-server-lwt)) diff --git a/cohttp-lwt.opam b/cohttp-lwt.opam index bd1bd54..a88bfcc 100644 --- a/cohttp-lwt.opam +++ b/cohttp-lwt.opam @@ -1,3 +1,4 @@ +version: "5.2.0" opam-version: "2.0" maintainer: "anil@recoil.org" authors: [ @@ -39,4 +40,4 @@ build: [ ["dune" "build" "-p" name "-j" jobs] ["dune" "runtest" "-p" name "-j" jobs] {with-test} ] -dev-repo: "git+https://github.com/mirage/ocaml-cohttp.git" +dev-repo: "git+https://github.com/mirage/ocaml-cohttp.git" \ No newline at end of file diff --git a/cohttp-lwt/src/server.ml b/cohttp-lwt/src/server.ml index 6ec5b20..922ee88 100644 --- a/cohttp-lwt/src/server.ml +++ b/cohttp-lwt/src/server.ml @@ -111,52 +111,58 @@ module Make (IO : S.IO) = struct `Response rsp)) (fun () -> Body.drain_body body) - let handle_response ~keep_alive oc res body handle_client = + let handle_response ~keep_alive oc res body conn_closed handle_client = IO.catch (fun () -> let flush = Response.flush res in Response.write ~flush (fun writer -> Body.write_body (Response.write_body writer) body) - res oc - >>= fun () -> if keep_alive then handle_client oc else Lwt.return_unit) + res oc) >>= function - | Ok () -> Lwt.return_unit + | Ok () -> + if keep_alive then handle_client oc + else + let () = conn_closed () in + Lwt.return_unit | Error e -> Log.info (fun m -> m "IO error while writing body: %a" IO.pp_error e); + conn_closed (); Body.drain_body body - - let rec handle_client ic oc conn callback = + let rec handle_client ic oc conn spec = Request.read ic >>= function - | `Eof -> Lwt.return_unit + | `Eof -> + spec.conn_closed conn; + Lwt.return_unit | `Invalid data -> Log.err (fun m -> m "invalid input %s while handling client" data); + spec.conn_closed conn; Lwt.return_unit | `Ok req -> ( let body = read_body ic req in - handle_request callback conn req body >>= function + handle_request spec.callback conn req body >>= function | `Response (res, body) -> let keep_alive = Request.is_keep_alive req in - handle_response ~keep_alive oc res body (fun oc -> - handle_client ic oc conn callback) + handle_response ~keep_alive oc res body + (fun () -> spec.conn_closed conn) + (fun oc -> handle_client ic oc conn spec) | `Expert (res, io_handler) -> Response.write_header res oc >>= fun () -> - io_handler ic oc >>= fun () -> - handle_client ic oc conn callback) + io_handler ic oc >>= fun () -> handle_client ic oc conn spec) let callback spec io_id ic oc = let conn_id = Cohttp.Connection.create () in let conn_closed () = spec.conn_closed (io_id, conn_id) in - Lwt.finalize + Lwt.catch (fun () -> - IO.catch (fun () -> handle_client ic oc (io_id, conn_id) spec.callback) + IO.catch (fun () -> handle_client ic oc (io_id, conn_id) spec) >>= function | Ok () -> Lwt.return_unit | Error e -> Log.info (fun m -> m "IO error while handling client: %a" IO.pp_error e); + conn_closed (); Lwt.return_unit) - (fun () -> - (* Clean up resources when the response stream terminates and call - * the user callback *) - conn_closed () |> Lwt.return) + (fun e -> + conn_closed (); + Lwt.fail e) end diff --git a/cohttp-mirage.opam b/cohttp-mirage.opam index 2e71327..d767aa5 100644 --- a/cohttp-mirage.opam +++ b/cohttp-mirage.opam @@ -1,3 +1,4 @@ +version: "5.2.0" opam-version: "2.0" maintainer: "anil@recoil.org" authors: ["Anil Madhavapeddy" "Thomas Gazagnaire"] @@ -38,4 +39,4 @@ build: [ ["dune" "build" "-p" name "-j" jobs] ["dune" "runtest" "-p" name "-j" jobs] {with-test} ] -dev-repo: "git+https://github.com/mirage/ocaml-cohttp.git" +dev-repo: "git+https://github.com/mirage/ocaml-cohttp.git" \ No newline at end of file diff --git a/cohttp-mirage/src/client.ml b/cohttp-mirage/src/client.ml index bd65b06..b34ebfd 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. * - * %%NAME%% %%VERSION%% + * cohttp v5.2.0 *) open Lwt.Infix diff --git a/cohttp-mirage/src/io.ml b/cohttp-mirage/src/io.ml index fe2f9d7..84b5466 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. * - * %%NAME%% %%VERSION%% + * cohttp v5.2.0 *) open Lwt.Infix diff --git a/cohttp-mirage/src/io.mli b/cohttp-mirage/src/io.mli index 23e9792..10c8710 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. * - * %%NAME%% %%VERSION%% + * cohttp v5.2.0 *) (** Cohttp IO implementation using Mirage channels. *) diff --git a/cohttp-mirage/src/static.ml b/cohttp-mirage/src/static.ml index 6ca5b56..bba69cf 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. * - * %%NAME%% %%VERSION%% + * cohttp v5.2.0 *) module Key = Mirage_kv.Key diff --git a/cohttp-mirage/src/static.mli b/cohttp-mirage/src/static.mli index 8f73c99..9ee4763 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. * - * %%NAME%% %%VERSION%% + * cohttp v5.2.0 *) (** Serve static HTTP sites from a Mirage key-value store. *) diff --git a/cohttp-top.opam b/cohttp-top.opam index 9b21332..d4b5b2e 100644 --- a/cohttp-top.opam +++ b/cohttp-top.opam @@ -1,3 +1,4 @@ +version: "5.2.0" opam-version: "2.0" maintainer: "anil@recoil.org" authors: [ @@ -30,4 +31,4 @@ build: [ ["dune" "build" "-p" name "-j" jobs] ["dune" "runtest" "-p" name "-j" jobs] {with-test} ] -dev-repo: "git+https://github.com/mirage/ocaml-cohttp.git" +dev-repo: "git+https://github.com/mirage/ocaml-cohttp.git" \ No newline at end of file diff --git a/cohttp.opam b/cohttp.opam index 9e6a95a..7e73c55 100644 --- a/cohttp.opam +++ b/cohttp.opam @@ -1,3 +1,4 @@ +version: "5.2.0" opam-version: "2.0" maintainer: "anil@recoil.org" authors: [ @@ -51,4 +52,4 @@ build: [ ["dune" "build" "-p" name "-j" jobs] ["dune" "runtest" "-p" name "-j" jobs] {with-test} ] -dev-repo: "git+https://github.com/mirage/ocaml-cohttp.git" +dev-repo: "git+https://github.com/mirage/ocaml-cohttp.git" \ No newline at end of file diff --git a/dune-project b/dune-project index ad62607..c3014fe 100644 --- a/dune-project +++ b/dune-project @@ -1,2 +1,3 @@ (lang dune 2.0) (name cohttp) +(version v5.2.0)