diff --git a/src/http/Client.zig b/src/http/Client.zig index 6ea56740..0eeeabd7 100644 --- a/src/http/Client.zig +++ b/src/http/Client.zig @@ -325,6 +325,11 @@ fn makeRequest(self: *Client, handle: *Handle, transfer: *Transfer) !void { } try errorCheck(c.curl_easy_setopt(easy, c.CURLOPT_PRIVATE, transfer)); + + // add credentials + if (req.credentials) |creds| { + try errorCheck(c.curl_easy_setopt(easy, c.CURLOPT_PROXYUSERPWD, creds.ptr)); + } } // Once soon as this is called, our "perform" loop is responsible for @@ -542,6 +547,7 @@ pub const Request = struct { body: ?[]const u8 = null, cookie_jar: *CookieJar, resource_type: ResourceType, + credentials: ?[:0]const u8 = null, // arbitrary data that can be associated with this request ctx: *anyopaque = undefined, @@ -633,6 +639,10 @@ pub const Transfer = struct { self.req.url = url; } + pub fn updateCredentials(self: *Transfer, userpwd: [:0]const u8) void { + self.req.credentials = userpwd; + } + pub fn replaceRequestHeaders(self: *Transfer, allocator: Allocator, headers: []const Http.Header) !void { self.req.headers.deinit();