Skip to content

Commit 9335901

Browse files
committed
remove deprecated ez_curl.multi
1 parent ac09f85 commit 9335901

File tree

5 files changed

+29
-65
lines changed

5 files changed

+29
-65
lines changed

src/request/unix/curl/dune

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
(public_name ez_api.curl_lwt)
2626
(optional)
2727
(modules ezCurl_lwt)
28-
(libraries ezCurl_multi))
28+
(libraries verbose curl.lwt ezCurl_common ezRequest_lwt))
2929

3030
(library
3131
(name ezCurl_lwt_i)

src/request/unix/curl/ezCurl_lwt.ml

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,31 @@
88
(* *)
99
(**************************************************************************)
1010

11-
include EzCurl_multi
11+
let make ?msg ?meth ?headers ~url l =
12+
EzCurl_common.log ?meth url msg;
13+
if !Verbose.v land 2 <> 0 then Format.printf "[ez_api] sent:\n%s@." (EzCurl_common.payload_to_string l);
14+
let r () =
15+
let r, c = EzCurl_common.init ?meth ?headers ~url l in
16+
Lwt.map (fun _code ->
17+
let rc = Curl.get_responsecode c in
18+
Curl.cleanup c;
19+
let data = Buffer.contents r in
20+
EzCurl_common.log ~meth:("RECV " ^ string_of_int rc) url msg;
21+
if !Verbose.v land 1 <> 0 then Format.printf "[ez_api] received:\n%s@." data;
22+
if rc >= 200 && rc < 300 then Ok data
23+
else Error (rc, Some data))
24+
(Curl_lwt.perform c) in
25+
Lwt.catch r (function
26+
| Curl.CurlException (_, i, s) -> Lwt.return (Error (i, Some s))
27+
| exn -> Lwt.return (Error (-1, Some (Printexc.to_string exn))))
28+
29+
module Interface = struct
30+
let get ?(meth="GET") ?headers ?msg url =
31+
make ?msg ~meth ?headers ~url []
32+
33+
let post ?(meth="POST") ?(content_type="application/json") ?(content="{}") ?headers
34+
?msg url =
35+
make ?msg ~meth ?headers ~url [ "", `content content, Some content_type ]
36+
end
37+
38+
include EzRequest_lwt.Make(Interface)

src/request/unix/curl/multi/dune

Lines changed: 0 additions & 14 deletions
This file was deleted.

src/request/unix/curl/multi/ezCurl_multi.ml

Lines changed: 0 additions & 38 deletions
This file was deleted.

src/request/unix/curl/multi/ezReq_lwt.ml

Lines changed: 0 additions & 11 deletions
This file was deleted.

0 commit comments

Comments
 (0)