add HTTP_VERSION_2_PRIOR_KNOWLEDGE
[ocurl.git] / examples / test_cb_exn.ml
blobd416199426e7bb780d92c0d88f2acd53c0e9aa25
1 (* Copyright (c) 2013, Thomas Leonard, <talex5@gmail.com> *)
3 open Printf
5 exception Abort
7 let () =
8 let open Curl in
9 let connection = init () in
10 let error_buffer = ref "" in
12 set_writefunction connection (fun _ -> raise Abort);
13 set_url connection "http://google.com";
14 set_errorbuffer connection error_buffer;
16 let run () =
17 try
18 perform connection;
19 with
20 | CurlException (CURLE_WRITE_ERROR,_,_) -> printf "ok\n%!"
21 | CurlException (error,_,name) -> printf "E: wrong error: %s %s : %s\n%!" name (Curl.strerror error) !error_buffer
22 | exn -> printf "E: wrong error: %s\n%!" (Printexc.to_string exn)
24 run ();
25 run ();
26 cleanup connection