From 674eac996b9ec7a798560e724bbb65245eda9823 Mon Sep 17 00:00:00 2001 From: madroach Date: Wed, 11 Feb 2026 16:36:56 -0500 Subject: [PATCH] set options after resetting curl handle (#29) * set options after resetting curl handle * format --------- Co-authored-by: Simon Cruanes --- src/core/ezcurl_core.ml | 9 +++++++-- src/core/ezcurl_core.mli | 5 ++++- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/core/ezcurl_core.ml b/src/core/ezcurl_core.ml index dc49ecc..82ee8f6 100644 --- a/src/core/ezcurl_core.ml +++ b/src/core/ezcurl_core.ml @@ -68,7 +68,11 @@ module Config = struct let to_string s = Format.asprintf "%a" pp s end -type t = { curl: Curl.t } [@@unboxed] +type t = { + curl: Curl.t; + set_opts: Curl.t -> unit; +} + type client = t let _top_mutex = Mutex.create () @@ -103,7 +107,7 @@ let make ?(set_opts = fun _ -> ()) ?cookiejar_file Curl.set_cookiefile curl file); if enable_session_cookies then Curl.set_cookiefile curl ""; set_opts curl; - { curl } + { curl; set_opts } let delete (self : t) = Curl.cleanup self.curl let _cfg_no_signal = ref false (* default: 0 *) @@ -403,6 +407,7 @@ module Make (IO : IO) : S with type 'a io = 'a IO.t = struct | None -> true, make () | Some c -> Curl.reset c.curl; + c.set_opts c.curl; false, c in _apply_config self config; diff --git a/src/core/ezcurl_core.mli b/src/core/ezcurl_core.mli index 6cdace4..b3f076b 100644 --- a/src/core/ezcurl_core.mli +++ b/src/core/ezcurl_core.mli @@ -15,7 +15,10 @@ module Config : sig val to_string : t -> string end -type t = private { curl: Curl.t } [@@unboxed] +type t = { + curl: Curl.t; + set_opts: Curl.t -> unit; +} (** A client, i.e. a cURL instance. The wrapping record has been present since 0.3 *)