Skip to content

Commit

Permalink
Update cohttp with last version of conduit
Browse files Browse the repository at this point in the history
  • Loading branch information
dinosaure committed Jun 30, 2020
1 parent 2627e1f commit 35b0194
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions cohttp-async/src/client.ml
Original file line number Diff line number Diff line change
Expand Up @@ -29,33 +29,35 @@ 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
|> Deferred.Or_error.ok_exn
>>= 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
Expand Down

0 comments on commit 35b0194

Please sign in to comment.