From c0ce91ec4f2fc683f027b4cc867e4b7ee2366889 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antonin=20D=C3=A9cimo?= Date: Wed, 10 Jul 2024 15:19:54 +0200 Subject: [PATCH] Fix Client overwriting its connection cache When given a custom context, the client would always overwrite it's connection cache. This prevents using a custom connection cache and a custom context. Access the connection cache directly. --- cohttp-lwt/src/client.ml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/cohttp-lwt/src/client.ml b/cohttp-lwt/src/client.ml index 406e364ee..1b7c074c0 100644 --- a/cohttp-lwt/src/client.ml +++ b/cohttp-lwt/src/client.ml @@ -6,15 +6,15 @@ module Make (Connection : S.Connection) = struct module No_cache = Connection_cache.Make_no_cache (Connection) module Request = Make.Request (Net.IO) - let cache = ref No_cache.(call (create ())) - let set_cache c = cache := c - type ctx = Net.ctx + let cache = ref None + let set_cache c = cache := Some c + let cache ?ctx = - match ctx with - | None -> !cache - | Some ctx -> No_cache.(call (create ~ctx ())) + match !cache with + | None -> No_cache.(call (create ?ctx ())) + | Some cache -> cache include Cohttp.Generic.Client.Make