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

@@ -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,
},
};