mirror of
https://github.com/c-cube/ezcurl.git
synced 2025-12-14 23:06:08 -05:00
Compare commits
No commits in common. "4b7d9ec7699b428152002abb327abb3a68a86bf8" and "742e51df9746927ea3b3b4c6702f048fd150f2c4" have entirely different histories.
4b7d9ec769
...
742e51df97
2 changed files with 4 additions and 23 deletions
|
|
@ -71,27 +71,17 @@ end
|
||||||
type t = { curl: Curl.t } [@@unboxed]
|
type t = { curl: Curl.t } [@@unboxed]
|
||||||
type client = t
|
type client = t
|
||||||
|
|
||||||
let _top_mutex = Mutex.create ()
|
|
||||||
|
|
||||||
let _with_mutex f =
|
|
||||||
Mutex.lock _top_mutex;
|
|
||||||
match f () with
|
|
||||||
| res ->
|
|
||||||
Mutex.unlock _top_mutex;
|
|
||||||
res
|
|
||||||
| exception e ->
|
|
||||||
Mutex.unlock _top_mutex;
|
|
||||||
raise e
|
|
||||||
|
|
||||||
let _init =
|
let _init =
|
||||||
let initialized = ref false in
|
let initialized = ref false in
|
||||||
|
let mutex = Mutex.create () in
|
||||||
fun () ->
|
fun () ->
|
||||||
_with_mutex @@ fun () ->
|
Mutex.lock mutex;
|
||||||
if not !initialized then (
|
if not !initialized then (
|
||||||
initialized := true;
|
initialized := true;
|
||||||
Curl.global_init Curl.CURLINIT_GLOBALALL;
|
Curl.global_init Curl.CURLINIT_GLOBALALL;
|
||||||
at_exit Curl.global_cleanup
|
at_exit Curl.global_cleanup
|
||||||
)
|
);
|
||||||
|
Mutex.unlock mutex
|
||||||
|
|
||||||
let make ?(set_opts = fun _ -> ()) ?cookiejar_file
|
let make ?(set_opts = fun _ -> ()) ?cookiejar_file
|
||||||
?(enable_session_cookies = false) () : t =
|
?(enable_session_cookies = false) () : t =
|
||||||
|
|
@ -106,9 +96,6 @@ let make ?(set_opts = fun _ -> ()) ?cookiejar_file
|
||||||
{ curl }
|
{ curl }
|
||||||
|
|
||||||
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 _get_no_signal () : bool = _with_mutex @@ fun () -> !_cfg_no_signal
|
|
||||||
let set_no_signal v = _with_mutex @@ fun () -> _cfg_no_signal := v
|
|
||||||
|
|
||||||
module Cookies = struct
|
module Cookies = struct
|
||||||
let reload_cookiejar (self : t) : unit =
|
let reload_cookiejar (self : t) : unit =
|
||||||
|
|
@ -144,7 +131,6 @@ let _apply_config (self : t) (config : Config.t) : unit =
|
||||||
opt_iter authmethod ~f:(Curl.set_httpauth self.curl);
|
opt_iter authmethod ~f:(Curl.set_httpauth self.curl);
|
||||||
opt_iter username ~f:(Curl.set_username self.curl);
|
opt_iter username ~f:(Curl.set_username self.curl);
|
||||||
opt_iter password ~f:(Curl.set_password self.curl);
|
opt_iter password ~f:(Curl.set_password self.curl);
|
||||||
Curl.set_nosignal self.curl (_get_no_signal ());
|
|
||||||
()
|
()
|
||||||
|
|
||||||
let _set_headers (self : t) (headers : _ list) : unit =
|
let _set_headers (self : t) (headers : _ list) : unit =
|
||||||
|
|
|
||||||
|
|
@ -37,11 +37,6 @@ val delete : t -> unit
|
||||||
val with_client : ?set_opts:(Curl.t -> unit) -> (t -> 'a) -> 'a
|
val with_client : ?set_opts:(Curl.t -> unit) -> (t -> 'a) -> 'a
|
||||||
(** Make a temporary client, call the function with it, then cleanup. *)
|
(** Make a temporary client, call the function with it, then cleanup. *)
|
||||||
|
|
||||||
val set_no_signal : bool -> unit
|
|
||||||
(** Set no_signal default value for each new client instance. Default is [true].
|
|
||||||
See [CURLOPT_NOSIGNAL].
|
|
||||||
@since NEXT_RELEASE *)
|
|
||||||
|
|
||||||
(** Cookie handling.
|
(** Cookie handling.
|
||||||
|
|
||||||
@since NEXT_RELEASE *)
|
@since NEXT_RELEASE *)
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue