Skip to content

Commit

Permalink
remove deprecated ez_curl.multi
Browse files Browse the repository at this point in the history
  • Loading branch information
maxtori committed Jul 8, 2024
1 parent ac09f85 commit 9335901
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 65 deletions.
2 changes: 1 addition & 1 deletion src/request/unix/curl/dune
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
(public_name ez_api.curl_lwt)
(optional)
(modules ezCurl_lwt)
(libraries ezCurl_multi))
(libraries verbose curl.lwt ezCurl_common ezRequest_lwt))

(library
(name ezCurl_lwt_i)
Expand Down
29 changes: 28 additions & 1 deletion src/request/unix/curl/ezCurl_lwt.ml
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,31 @@
(* *)
(**************************************************************************)

include EzCurl_multi
let make ?msg ?meth ?headers ~url l =
EzCurl_common.log ?meth url msg;
if !Verbose.v land 2 <> 0 then Format.printf "[ez_api] sent:\n%s@." (EzCurl_common.payload_to_string l);
let r () =
let r, c = EzCurl_common.init ?meth ?headers ~url l in
Lwt.map (fun _code ->
let rc = Curl.get_responsecode c in
Curl.cleanup c;
let data = Buffer.contents r in
EzCurl_common.log ~meth:("RECV " ^ string_of_int rc) url msg;
if !Verbose.v land 1 <> 0 then Format.printf "[ez_api] received:\n%s@." data;
if rc >= 200 && rc < 300 then Ok data
else Error (rc, Some data))
(Curl_lwt.perform c) in
Lwt.catch r (function
| Curl.CurlException (_, i, s) -> Lwt.return (Error (i, Some s))
| exn -> Lwt.return (Error (-1, Some (Printexc.to_string exn))))

module Interface = struct
let get ?(meth="GET") ?headers ?msg url =
make ?msg ~meth ?headers ~url []

let post ?(meth="POST") ?(content_type="application/json") ?(content="{}") ?headers
?msg url =
make ?msg ~meth ?headers ~url [ "", `content content, Some content_type ]
end

include EzRequest_lwt.Make(Interface)
14 changes: 0 additions & 14 deletions src/request/unix/curl/multi/dune

This file was deleted.

38 changes: 0 additions & 38 deletions src/request/unix/curl/multi/ezCurl_multi.ml

This file was deleted.

11 changes: 0 additions & 11 deletions src/request/unix/curl/multi/ezReq_lwt.ml

This file was deleted.

0 comments on commit 9335901

Please sign in to comment.