set options after resetting curl handle (#29)
Some checks failed
format / format (push) Has been cancelled
github pages / deploy (push) Has been cancelled
build / Build (push) Has been cancelled

* set options after resetting curl handle

* format

---------

Co-authored-by: Simon Cruanes <simon.cruanes.2007@m4x.org>
This commit is contained in:
madroach 2026-02-11 16:36:56 -05:00 committed by GitHub
parent 44a2b9f149
commit 674eac996b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 11 additions and 3 deletions

View file

@ -68,7 +68,11 @@ module Config = struct
let to_string s = Format.asprintf "%a" pp s let to_string s = Format.asprintf "%a" pp s
end end
type t = { curl: Curl.t } [@@unboxed] type t = {
curl: Curl.t;
set_opts: Curl.t -> unit;
}
type client = t type client = t
let _top_mutex = Mutex.create () let _top_mutex = Mutex.create ()
@ -103,7 +107,7 @@ let make ?(set_opts = fun _ -> ()) ?cookiejar_file
Curl.set_cookiefile curl file); Curl.set_cookiefile curl file);
if enable_session_cookies then Curl.set_cookiefile curl ""; if enable_session_cookies then Curl.set_cookiefile curl "";
set_opts curl; set_opts curl;
{ curl } { curl; set_opts }
let delete (self : t) = Curl.cleanup self.curl let delete (self : t) = Curl.cleanup self.curl
let _cfg_no_signal = ref false (* default: 0 *) 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 () | None -> true, make ()
| Some c -> | Some c ->
Curl.reset c.curl; Curl.reset c.curl;
c.set_opts c.curl;
false, c false, c
in in
_apply_config self config; _apply_config self config;

View file

@ -15,7 +15,10 @@ module Config : sig
val to_string : t -> string val to_string : t -> string
end 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 (** A client, i.e. a cURL instance. The wrapping record has been present since
0.3 *) 0.3 *)