http: add use_proxy bool in connection

This commit is contained in:
Pierre Tachoire
2025-08-21 12:03:46 +02:00
parent bc7e1e07f4
commit 159bd06a56
2 changed files with 10 additions and 2 deletions

View File

@@ -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 {