mirror of
https://github.com/c-cube/ezcurl.git
synced 2025-12-05 19:00:34 -05:00
feat: add Ezcurl.Cookies module, get/set/transfer them
This commit is contained in:
parent
a8ad44d39e
commit
71a37788ac
2 changed files with 31 additions and 6 deletions
|
|
@ -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 =
|
||||
|
|
|
|||
|
|
@ -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
|
||||
*)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue