From 3049bb0b9f8f33814aeece3365cd17c02158a2a5 Mon Sep 17 00:00:00 2001 From: Karl Seguin Date: Thu, 10 Jul 2025 16:27:09 +0800 Subject: [PATCH 1/4] Fix async https requests over a http forward proxy XHR requests to https (which is most XHR requests) currently don't work with the implementation proxy because of this. --- src/http/client.zig | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/http/client.zig b/src/http/client.zig index c3dbb41b..81c84394 100644 --- a/src/http/client.zig +++ b/src/http/client.zig @@ -240,6 +240,10 @@ pub const Client = struct { const proxy_type = self.proxy_type orelse return false; return proxy_type == .forward; } + + fn isProxy(self: *const Client) bool { + return self.proxy_type != null; + } }; const RequestOpts = struct { @@ -792,8 +796,12 @@ pub const Request = struct { .conn = .{ .handler = async_handler, .protocol = .{ .plain = {} } }, }; - if (self._client.isConnectProxy() and self._proxy_secure) log.warn(.http, "ASYNC TLS CONNECT no impl.", .{}); - if (self._request_secure) { + if (self._client.isConnectProxy() and self._proxy_secure) { + log.warn(.http, "not implemented", .{ .feature = "async tls connect" }); + } + + const is_proxy = self._client.isProxy(); + if ((is_proxy and self._proxy_secure) or (!is_proxy and self._request_secure)) { if (self._connection_from_keepalive) { // If the connection came from the keepalive pool, than we already // have a TLS Connection. From 4a12d045e42d0a0010f555011c4d8d06bda972b0 Mon Sep 17 00:00:00 2001 From: Karl Seguin Date: Thu, 10 Jul 2025 17:10:58 +0800 Subject: [PATCH 2/4] Update src/http/client.zig Co-authored-by: Sjors <72333389+sjorsdonkers@users.noreply.github.com> --- src/http/client.zig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/http/client.zig b/src/http/client.zig index 81c84394..fa3c47c1 100644 --- a/src/http/client.zig +++ b/src/http/client.zig @@ -801,7 +801,7 @@ pub const Request = struct { } const is_proxy = self._client.isProxy(); - if ((is_proxy and self._proxy_secure) or (!is_proxy and self._request_secure)) { + if ((is_proxy and self._proxy_secure) or (!is_forward_proxy and self._request_secure)) { if (self._connection_from_keepalive) { // If the connection came from the keepalive pool, than we already // have a TLS Connection. From 795c925ba18e31c0007095e8e9a37dcdd3ec2e34 Mon Sep 17 00:00:00 2001 From: Karl Seguin Date: Fri, 11 Jul 2025 09:49:40 +0800 Subject: [PATCH 3/4] Revert "Update src/http/client.zig" This reverts commit 4a12d045e42d0a0010f555011c4d8d06bda972b0. --- src/http/client.zig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/http/client.zig b/src/http/client.zig index fa3c47c1..81c84394 100644 --- a/src/http/client.zig +++ b/src/http/client.zig @@ -801,7 +801,7 @@ pub const Request = struct { } const is_proxy = self._client.isProxy(); - if ((is_proxy and self._proxy_secure) or (!is_forward_proxy and self._request_secure)) { + if ((is_proxy and self._proxy_secure) or (!is_proxy and self._request_secure)) { if (self._connection_from_keepalive) { // If the connection came from the keepalive pool, than we already // have a TLS Connection. From b387fd2bd45292a7d1c6faede602a94869c8154f Mon Sep 17 00:00:00 2001 From: Karl Seguin Date: Fri, 11 Jul 2025 17:38:31 +0800 Subject: [PATCH 4/4] Update src/http/client.zig Co-authored-by: Sjors <72333389+sjorsdonkers@users.noreply.github.com> --- src/http/client.zig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/http/client.zig b/src/http/client.zig index 81c84394..41f432a6 100644 --- a/src/http/client.zig +++ b/src/http/client.zig @@ -801,7 +801,7 @@ pub const Request = struct { } const is_proxy = self._client.isProxy(); - if ((is_proxy and self._proxy_secure) or (!is_proxy and self._request_secure)) { + if ((is_proxy and self._proxy_secure) or (!self._client.isForwardProxy() and self._request_secure)) { if (self._connection_from_keepalive) { // If the connection came from the keepalive pool, than we already // have a TLS Connection.