diff --git a/src/http/Client.zig b/src/http/Client.zig index fad98e8b..094aedd8 100644 --- a/src/http/Client.zig +++ b/src/http/Client.zig @@ -278,9 +278,11 @@ fn requestFailed(self: *Client, transfer: *Transfer, err: anyerror) void { pub fn changeProxy(self: *Client, proxy: [:0]const u8) !void { try self.ensureNoActiveConnection(); - for (self.handles.handles) |h| { + for (self.handles.handles) |*h| { + h.conn.opts.use_proxy = true; try errorCheck(c.curl_easy_setopt(h.conn.easy, c.CURLOPT_PROXY, proxy.ptr)); } + self.blocking.conn.opts.use_proxy = true; try errorCheck(c.curl_easy_setopt(self.blocking.conn.easy, c.CURLOPT_PROXY, proxy.ptr)); } @@ -290,10 +292,12 @@ pub fn restoreOriginalProxy(self: *Client) !void { try self.ensureNoActiveConnection(); const proxy = if (self.http_proxy) |p| p.ptr else null; - for (self.handles.handles) |h| { + for (self.handles.handles) |*h| { + h.conn.opts.use_proxy = proxy != null; try errorCheck(c.curl_easy_setopt(h.conn.easy, c.CURLOPT_PROXY, proxy)); } try errorCheck(c.curl_easy_setopt(self.blocking.conn.easy, c.CURLOPT_PROXY, proxy)); + self.blocking.conn.opts.use_proxy = proxy != null; } fn makeRequest(self: *Client, handle: *Handle, transfer: *Transfer) !void { diff --git a/src/http/Http.zig b/src/http/Http.zig index 59b5b621..872350eb 100644 --- a/src/http/Http.zig +++ b/src/http/Http.zig @@ -94,6 +94,7 @@ pub const Connection = struct { opts: Connection.Opts, const Opts = struct { + use_proxy: bool, proxy_bearer_token: ?[:0]const u8, }; @@ -112,9 +113,11 @@ pub const Connection = struct { try errorCheck(c.curl_easy_setopt(easy, c.CURLOPT_REDIR_PROTOCOLS_STR, "HTTP,HTTPS")); // remove FTP and FTPS from the default // proxy + var use_proxy = false; if (opts.http_proxy) |proxy| { try errorCheck(c.curl_easy_setopt(easy, c.CURLOPT_PROXY, proxy.ptr)); try errorCheck(c.curl_easy_setopt(easy, c.CURLOPT_SUPPRESS_CONNECT_HEADERS, @as(c_long, 1))); + use_proxy = true; } // tls @@ -156,6 +159,7 @@ pub const Connection = struct { return .{ .easy = easy, .opts = .{ + .use_proxy = use_proxy, .proxy_bearer_token = opts.proxy_bearer_token, }, };