A batteries included HTTP/1.1 client in OCaml
at main 20 lines 769 B view raw
1(*--------------------------------------------------------------------------- 2 Copyright (c) 2025 Anil Madhavapeddy <anil@recoil.org>. All rights reserved. 3 SPDX-License-Identifier: ISC 4 ---------------------------------------------------------------------------*) 5 6(** Test using One module directly without connection pooling *) 7let () = 8 Vlog.setup_test ~level:Logs.Debug (); 9 Crypto_rng_unix.use_default (); 10 Eio_main.run @@ fun env -> 11 Eio.Switch.run @@ fun sw -> 12 try 13 let response = 14 Requests.One.get ~sw ~clock:env#clock ~net:env#net 15 "https://opam.ocaml.org" 16 in 17 Fmt.pr "Status: %d\n%!" (Requests.Response.status_code response) 18 with e -> 19 Fmt.pr "Exception: %s\n%!" (Printexc.to_string e); 20 Printexc.print_backtrace stdout