Source

ocaml-bitbucket / xcurl.ml

Diff from to

File xcurl.ml

 let ok200 = function
-  | 200, v -> `Ok v
-  | n, mes -> `Error (`Http (n, mes))
+  | _, 200, v -> `Ok v
+  | url, n, mes -> `Error (`Http (url, n, mes))
 
 let get_string f = 
   let h = new Curl.handle in
   h#set_writefunction (fun s -> Buffer.add_string buf s; String.length s);
   h#perform;
   let code = h#get_httpcode in
+  let url = h#get_effectiveurl in
   h#cleanup; (* Need to flush out cookies *)
-  ok200 (code, Buffer.contents buf)
+  ok200 (url, code, Buffer.contents buf)
 
 let download dst f =
   let h = new Curl.handle in
     output_string oc s; String.length s);
   h#perform;
   let code = h#get_httpcode in
+  let url = h#get_effectiveurl in
   h#cleanup; (* Need to flush out cookies *)
   close_out oc;
   match code with
   | 200 -> Unix.rename tmp dst; `Ok dst
-  | e -> `Error (`Http (e, tmp))
+  | e -> `Error (`Http (url, e, tmp))