Commits

camlspotter  committed 74f9d22
  • Participants
  • Parent commits ed5011a

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;
+  let code = h#get_httpcode in
   h#cleanup; (* Need to flush out cookies *)
-  ok200 (h#get_httpcode, Buffer.contents buf)
+  ok200 (code, Buffer.contents buf)
 
 let download dst f =
   let h = new Curl.handle in
   h#set_writefunction (fun s -> 
     output_string oc s; String.length s);
   h#perform;
+  let code = h#get_httpcode in
   h#cleanup; (* Need to flush out cookies *)
   close_out oc;
-  match h#get_httpcode with
+  match code with
   | 200 -> Unix.rename tmp dst; `Ok dst
   | e -> `Error (`Http (e, tmp))