Skip to content

Instantly share code, notes, and snippets.

@specialblend
Created September 15, 2023 01:03
Show Gist options
  • Save specialblend/90c074fa7c5ebc24a29239c4ccbc983a to your computer and use it in GitHub Desktop.
Save specialblend/90c074fa7c5ebc24a29239c4ccbc983a to your computer and use it in GitHub Desktop.
let () =
Eio_main.run
@@ fun env ->
Mirage_crypto_rng_eio.run (module Mirage_crypto_rng.Fortuna) env
@@ fun () ->
let net = Eio.Stdenv.net env in
Eio.Net.with_tcp_connect ~service:"https" ~host:"www.example.org" net
@@ fun conn ->
let conn =
Tls_eio.client_of_flow
(Tls.Config.client ~authenticator:(fun ?ip:_ ~host:_ _ -> Ok None) ())
?host:
(Domain_name.of_string_exn "www.example.org"
|> Domain_name.host
|> Result.to_option)
conn
in
Cohttp_eio.Client.get ~conn ~host:"https://www.example.org"
(object
method net = net
end)
"/"
|> Cohttp_eio.Client.read_fixed
|> print_endline
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment