From 76e1ac3db32b398ef59a19b28b19323872aa5787 Mon Sep 17 00:00:00 2001 From: koplenov Date: Thu, 28 Dec 2023 12:49:25 +0300 Subject: [PATCH] net.http: support `-d no_vschannel` on windows, to fix long waits, while connecting on some systems (#20265) --- vlib/net/http/{backend_nix.c.v => backend.c.v} | 7 +++++++ .../{backend_windows.c.v => backend_vschannel_windows.c.v} | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) rename vlib/net/http/{backend_nix.c.v => backend.c.v} (87%) rename vlib/net/http/{backend_windows.c.v => backend_vschannel_windows.c.v} (91%) diff --git a/vlib/net/http/backend_nix.c.v b/vlib/net/http/backend.c.v similarity index 87% rename from vlib/net/http/backend_nix.c.v rename to vlib/net/http/backend.c.v index 0a28406511..19924e5169 100644 --- a/vlib/net/http/backend_nix.c.v +++ b/vlib/net/http/backend.c.v @@ -7,6 +7,13 @@ import net.ssl import strings fn (req &Request) ssl_do(port int, method Method, host_name string, path string) !Response { + $if windows && !no_vschannel ? { + return vschannel_ssl_do(req, port, method, host_name, path) + } + return net_ssl_do(req, port, method, host_name, path) +} + +fn net_ssl_do(req &Request, port int, method Method, host_name string, path string) !Response { mut ssl_conn := ssl.new_ssl_conn( verify: req.verify cert: req.cert diff --git a/vlib/net/http/backend_windows.c.v b/vlib/net/http/backend_vschannel_windows.c.v similarity index 91% rename from vlib/net/http/backend_windows.c.v rename to vlib/net/http/backend_vschannel_windows.c.v index 6ecd26dec3..50c6b49ef8 100644 --- a/vlib/net/http/backend_windows.c.v +++ b/vlib/net/http/backend_vschannel_windows.c.v @@ -15,7 +15,7 @@ pub struct C.TlsContext {} fn C.new_tls_context() C.TlsContext -fn (req &Request) ssl_do(port int, method Method, host_name string, path string) !Response { +fn vschannel_ssl_do(req &Request, port int, method Method, host_name string, path string) !Response { mut ctx := C.new_tls_context() C.vschannel_init(&ctx) mut buff := unsafe { malloc_noscan(C.vsc_init_resp_buff_size) }