File tree Expand file tree Collapse file tree 2 files changed +2
-28
lines changed
Expand file tree Collapse file tree 2 files changed +2
-28
lines changed Original file line number Diff line number Diff line change 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)
Original file line number Diff line number Diff line change 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
You can’t perform that action at this time.
0 commit comments