From 27c853d8c33d66d9911ad3fa9c005b904699575b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antonin=20D=C3=A9cimo?= Date: Wed, 19 Jun 2024 17:07:29 +0200 Subject: [PATCH 1/3] Use Ivar.fill_exn instead of Ivar.fill MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Antonin Décimo --- cohttp-async/src/client.ml | 2 +- cohttp-curl-async/src/cohttp_curl_async.ml | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/cohttp-async/src/client.ml b/cohttp-async/src/client.ml index c9535416d..364ead168 100644 --- a/cohttp-async/src/client.ml +++ b/cohttp-async/src/client.ml @@ -109,7 +109,7 @@ module Connection = struct req oc >>= fun () -> read_response ic >>= fun (resp, body) -> - Ivar.fill res (resp, `Pipe body); + Ivar.fill_exn res (resp, `Pipe body); (* block starting any more requests until the consumer has finished reading this request *) Pipe.closed body) |> don't_wait_for; diff --git a/cohttp-curl-async/src/cohttp_curl_async.ml b/cohttp-curl-async/src/cohttp_curl_async.ml index e955047cd..e94e2893d 100644 --- a/cohttp-curl-async/src/cohttp_curl_async.ml +++ b/cohttp-curl-async/src/cohttp_curl_async.ml @@ -40,7 +40,7 @@ module Context = struct | None -> () | Some w -> Hashtbl.remove t.wakeners h; - Ivar.fill w code); + Ivar.fill_exn w code); finished s in let on_readable fd = @@ -102,7 +102,7 @@ module Context = struct | Some _, true -> () | None, true -> set_event (Some (create_event fd what)) | Some ivar, false -> - Ivar.fill ivar (); + Ivar.fill_exn ivar (); set_event None in update current.fd @@ -168,7 +168,8 @@ module Request = struct timeout in Cohttp_curl.Request.create ?timeout_ms ?headers method_ ~uri ~input - ~output ~on_response:(Ivar.fill response_ready) + ~output + ~on_response:(Ivar.fill_exn response_ready) in { base; response_ready = Ivar.read response_ready; body_ready } end From cbf8bb01b824a6d49ff4113765367d9e8cd1c3d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antonin=20D=C3=A9cimo?= Date: Wed, 19 Jun 2024 17:16:24 +0200 Subject: [PATCH 2/3] Leave response flush to its default value in servers MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Antonin Décimo --- cohttp-async/src/server.ml | 3 +-- cohttp-lwt/src/server.ml | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/cohttp-async/src/server.ml b/cohttp-async/src/server.ml index 308ea5124..a23db905d 100644 --- a/cohttp-async/src/server.ml +++ b/cohttp-async/src/server.ml @@ -85,7 +85,6 @@ let handle_client handle_request sock rd wr = Http.Request.is_keep_alive req && Http.Response.is_keep_alive res in - let flush = Http.Response.flush res in let res = let headers = Http.Header.add_unless_exists @@ -95,7 +94,7 @@ let handle_client handle_request sock rd wr = in { res with Http.Response.headers } in - Io.Response.write ~flush + Io.Response.write (Body.Private.write_body Io.Response.write_body res_body) res wr >>= fun () -> diff --git a/cohttp-lwt/src/server.ml b/cohttp-lwt/src/server.ml index e85e867d4..eed02cf5a 100644 --- a/cohttp-lwt/src/server.ml +++ b/cohttp-lwt/src/server.ml @@ -116,8 +116,7 @@ module Make (IO : S.IO) = struct let handle_response ~keep_alive oc res body conn_closed handle_client = IO.catch (fun () -> - let flush = Response.flush res in - Response.write ~flush + Response.write (fun writer -> Body.write_body (Response.write_body writer) body) res oc) >>= function From 0aced7d2131fd887e96a8b9473f0e160dc7cc987 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antonin=20D=C3=A9cimo?= Date: Wed, 19 Jun 2024 17:08:12 +0200 Subject: [PATCH 3/3] Don't declare transitive dependencies MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Antonin Décimo --- http/test/bytebuffer/dune | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/http/test/bytebuffer/dune b/http/test/bytebuffer/dune index 5898a7cff..c89fd56c6 100644 --- a/http/test/bytebuffer/dune +++ b/http/test/bytebuffer/dune @@ -1,14 +1,6 @@ (library (name bytebuffer_tests) - (libraries - http_bytebuffer - ;; This is because of the (implicit_transitive_deps false) - ;; in dune-project - ppx_expect.config - ppx_expect.config_types - ppx_expect - base - ppx_inline_test.config) + (libraries http_bytebuffer) (inline_tests) (preprocess (pps ppx_expect)))