diff --git a/cohttp-async/src/client.ml b/cohttp-async/src/client.ml index a92596ab11..7b8b1cf7aa 100644 --- a/cohttp-async/src/client.ml +++ b/cohttp-async/src/client.ml @@ -29,20 +29,18 @@ module Net = struct | _ -> Or_error.error "Failed to resolve Uri" uri Uri_sexp.sexp_of_t let connect_uri ?interrupt:_ ?ssl_ctx uri = - let tcp_cfg = - let addr = Ipaddr_unix.to_inet_addr addr in - Conduit_async.TCP.Inet (Socket.Address.Inet.create addr ~port) in match (Uri.scheme uri, ssl_ctx) with | Some "httpunix", _ -> - let tcp_cfg = Conduit_async_tcp.Unix (Socket.Address.Unix.create host) in + let host = Uri.host_with_default ~default:"localhost" uri in + let tcp_cfg = Conduit_async.TCP.Unix (Socket.Address.Unix.create host) in Conduit_async.connect tcp_cfg Conduit_async.TCP.protocol | Some "https", Some ctx -> lookup uri |> Deferred.Or_error.ok_exn - >>= fun (host, addr, port) -> + >>= fun (_, addr, port) -> let tcp_cfg = let addr = Ipaddr_unix.to_inet_addr addr in - Conduit_async_tcp.Inet (Socket.Address.Inet.create addr ~port) in + Conduit_async.TCP.Inet (Socket.Address.Inet.create addr ~port) in Conduit_async.connect (ctx, tcp_cfg) Conduit_async_ssl.TCP.protocol | Some "https", None -> lookup uri @@ -50,12 +48,16 @@ module Net = struct >>= fun (host, addr, port) -> let tcp_cfg = let addr = Ipaddr_unix.to_inet_addr addr in - Conduit_async_tcp.Inet (Socket.Address.Inet.create addr ~port) in + Conduit_async.TCP.Inet (Socket.Address.Inet.create addr ~port) in let ctx = Conduit_async_ssl.context ~hostname:host () in + Conduit_async.connect (ctx, tcp_cfg) Conduit_async_ssl.TCP.protocol | _ -> lookup uri |> Deferred.Or_error.ok_exn - >>= fun (host, addr, port) -> + >>= fun (_, addr, port) -> + let tcp_cfg = + let addr = Ipaddr_unix.to_inet_addr addr in + Conduit_async.TCP.Inet (Socket.Address.Inet.create addr ~port) in Conduit_async.connect tcp_cfg Conduit_async.TCP.protocol let failwith fmt = Stdlib.Format.kasprintf failwith fmt