mirror of
https://github.com/lightpanda-io/browser.git
synced 2026-03-22 04:34:44 +00:00
Merge pull request #1758 from lightpanda-io/http-auth-challenge
http: handle auth challenge for non-proxy auth
This commit is contained in:
@@ -377,6 +377,10 @@ pub const Connection = struct {
|
||||
try libcurl.curl_easy_setopt(self.easy, .proxy_user_pwd, creds.ptr);
|
||||
}
|
||||
|
||||
pub fn setCredentials(self: *const Connection, creds: [:0]const u8) !void {
|
||||
try libcurl.curl_easy_setopt(self.easy, .user_pwd, creds.ptr);
|
||||
}
|
||||
|
||||
pub fn setCallbacks(
|
||||
self: *const Connection,
|
||||
comptime header_cb: libcurl.CurlHeaderFunction,
|
||||
|
||||
@@ -718,7 +718,11 @@ fn makeRequest(self: *Client, conn: *Net.Connection, transfer: *Transfer) anyerr
|
||||
|
||||
// add credentials
|
||||
if (req.credentials) |creds| {
|
||||
if (transfer._auth_challenge != null and transfer._auth_challenge.?.source == .proxy) {
|
||||
try conn.setProxyCredentials(creds);
|
||||
} else {
|
||||
try conn.setCredentials(creds);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -148,6 +148,7 @@ pub const CurlOption = enum(c.CURLoption) {
|
||||
cookie = c.CURLOPT_COOKIE,
|
||||
private = c.CURLOPT_PRIVATE,
|
||||
proxy_user_pwd = c.CURLOPT_PROXYUSERPWD,
|
||||
user_pwd = c.CURLOPT_USERPWD,
|
||||
header_data = c.CURLOPT_HEADERDATA,
|
||||
header_function = c.CURLOPT_HEADERFUNCTION,
|
||||
write_data = c.CURLOPT_WRITEDATA,
|
||||
@@ -512,6 +513,7 @@ pub fn curl_easy_setopt(easy: *Curl, comptime option: CurlOption, value: anytype
|
||||
.accept_encoding,
|
||||
.custom_request,
|
||||
.cookie,
|
||||
.user_pwd,
|
||||
.proxy_user_pwd,
|
||||
.copy_post_fields,
|
||||
=> blk: {
|
||||
|
||||
Reference in New Issue
Block a user