Skip to content

Commit

Permalink
Fix Client overwriting its connection cache
Browse files Browse the repository at this point in the history
When given a custom context, the client would always overwrite its
connection cache. This prevents using a custom connection cache and a
custom context. Access the connection cache directly.
  • Loading branch information
MisterDA committed Jul 10, 2024
1 parent 41a2460 commit d345f14
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions cohttp-lwt/src/client.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit d345f14

Please sign in to comment.