diff --git a/src/core/Ezcurl_core.ml b/src/core/Ezcurl_core.ml index 892625f..e0cb97d 100644 --- a/src/core/Ezcurl_core.ml +++ b/src/core/Ezcurl_core.ml @@ -95,8 +95,19 @@ let make ?(set_opts = fun _ -> ()) ?cookiejar_file { curl } let delete (self : t) = Curl.cleanup self.curl -let reload_cookiejar (self : t) : unit = Curl.set_cookielist self.curl "RELOAD" -let flush_cookiejar (self : t) : unit = Curl.set_cookielist self.curl "FLUSH" + +module Cookies = struct + let reload_cookiejar (self : t) : unit = + Curl.set_cookielist self.curl "RELOAD" + + let flush_cookiejar (self : t) : unit = Curl.set_cookielist self.curl "FLUSH" + let get_cookies self = Curl.get_cookielist self.curl + + let set_cookies self (l : string list) = + List.iter (Curl.set_cookielist self.curl) l + + let transfer c1 c2 = set_cookies c2 @@ get_cookies c1 +end (* set options *) let _apply_config (self : t) (config : Config.t) : unit = diff --git a/src/core/Ezcurl_core.mli b/src/core/Ezcurl_core.mli index c65d3ba..721ceba 100644 --- a/src/core/Ezcurl_core.mli +++ b/src/core/Ezcurl_core.mli @@ -37,16 +37,30 @@ val delete : t -> unit val with_client : ?set_opts:(Curl.t -> unit) -> (t -> 'a) -> 'a (** Make a temporary client, call the function with it, then cleanup. *) -val flush_cookiejar : t -> unit -(** If [cookiejar_file] was provided in {!make}, this flushes the current set of cookies +(** Cookie handling. + +@since NEXT_RELEASE *) +module Cookies : sig + val flush_cookiejar : t -> unit + (** If [cookiejar_file] was provided in {!make}, this flushes the current set of cookies to the provided file. @since NEXT_RELEASE *) -val reload_cookiejar : t -> unit -(** If [cookiejar_file] was provided in {!make}, this reloads cookies from + val reload_cookiejar : t -> unit + (** If [cookiejar_file] was provided in {!make}, this reloads cookies from the provided file. @since NEXT_RELEASE *) + val get_cookies : t -> string list + (** Get cookie list (in netscape format) *) + + val set_cookies : t -> string list -> unit + (** Set cookie list (in netscape format) *) + + val transfer : t -> t -> unit + (** [transfer c1 c2] copies cookies in [c1] into [c2] *) +end + (* TODO: duphandle is deprecated, how do we iterate on options? val copy : t -> t *)