Hello I am learning how to use Cohttp. I wrote this code on top of “utop”
opam install cohttp-lwt-unix cohttp-async
Then run utop
#require "cohttp";;
#require "lwt";;
#require "cohttp-lwt-unix";;
open Cohttp;;
open Lwt;;
open Cohttp_lwt_unix;;
let body =
Client.get (Uri.of_string "https://api.weather.gov/points/48.505501999717,-118.504999000172") >>= fun (resp, body) ->
let code = resp |> Response.status |> Code.code_of_status in
Printf.printf "Response code: %d\n" code;
Printf.printf "Headers: %s\n" (resp |> Response.headers |> Header.to_string);
body |> Cohttp_lwt.Body.to_string >|= fun body ->
Printf.printf "Body of length: %d\n" (String.length body);
body;;
let () =
let body = Lwt_main.run body in
print_endline ("received body: \n" ^ body);;
But this code returns an error "Exception: Failure “No SSL or TLS support compiled into Conduit”