Skip to content

Commit 1300836

Browse files
authored
Merge pull request #118 from maxtori/fix-asynchronous-mistake
fix asynchronous curl_lwt
2 parents 4bb450b + 2857e1c commit 1300836

File tree

2 files changed

+2
-28
lines changed

2 files changed

+2
-28
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_common ezRequest_lwt))
28+
(libraries ezCurl_multi))
2929

3030
(library
3131
(name ezCurl_lwt_i)

src/request/unix/curl/ezCurl_lwt.ml

Lines changed: 1 addition & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -8,30 +8,4 @@
88
(* *)
99
(**************************************************************************)
1010

11-
let make ?msg ?meth ?content ?content_type ?headers url =
12-
EzCurl_common.log ?meth url msg;
13-
if !Verbose.v land 2 <> 0 then Format.printf "sent:\n%s@." (Option.value ~default:"" content);
14-
let r () =
15-
let r, c = EzCurl_common.init ?meth ?content ?content_type ?headers url in
16-
Curl.perform c;
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 "received:\n%s@." data;
22-
if rc >= 200 && rc < 300 then Lwt.return_ok data
23-
else Lwt.return_error (rc, Some data) in
24-
Lwt.catch r (function
25-
| Curl.CurlException (_, i, s) -> Lwt.return (Error (i, Some s))
26-
| exn -> Lwt.return (Error (-1, Some (Printexc.to_string exn))))
27-
28-
module Interface = struct
29-
let get ?(meth="GET") ?headers ?msg url =
30-
make ?msg ~meth ?headers url
31-
32-
let post ?(meth="POST") ?(content_type="application/json") ?(content="{}") ?headers
33-
?msg url =
34-
make ?msg ~meth ?headers ~content ~content_type url
35-
end
36-
37-
include EzRequest_lwt.Make(Interface)
11+
include EzCurl_multi

0 commit comments

Comments
 (0)