Commits

camlspotter committed 1a24c47

merged xcurl.ml

  • Participants
  • Parent commits 9aad09d
  • Branches dev

Comments (0)

Files changed (1)

   let buf = Buffer.create 100 in
   h#set_writefunction (fun s -> Buffer.add_string buf s; String.length s);
   h#perform;
+  h#cleanup; (* Need to flush out cookies *)
   ok200 (h#get_httpcode, Buffer.contents buf)
 
+let download dst f =
+  let h = new Curl.handle in
+  f h;
+  let tmp = dst ^ ".tmp" in
+  let oc = open_out_bin tmp in
+  h#set_writefunction (fun s -> 
+    output_string oc s; String.length s);
+  h#perform;
+  h#cleanup; (* Need to flush out cookies *)
+  close_out oc;
+  ok200 (h#get_httpcode, Unix.rename tmp dst)
+