diff --git a/src/browser/HttpClient.zig b/src/browser/HttpClient.zig index 3fb5ac5a..c49d7e1f 100644 --- a/src/browser/HttpClient.zig +++ b/src/browser/HttpClient.zig @@ -1270,8 +1270,12 @@ pub const Transfer = struct { if (conn.getResponseHeader("WWW-Authenticate", 0)) |hdr| { transfer._auth_challenge = http.AuthChallenge.parse(status, .server, hdr.value) catch null; + } else if (conn.getConnectHeader("WWW-Authenticate", 0)) |hdr| { + transfer._auth_challenge = http.AuthChallenge.parse(status, .server, hdr.value) catch null; } else if (conn.getResponseHeader("Proxy-Authenticate", 0)) |hdr| { transfer._auth_challenge = http.AuthChallenge.parse(status, .proxy, hdr.value) catch null; + } else if (conn.getConnectHeader("Proxy-Authenticate", 0)) |hdr| { + transfer._auth_challenge = http.AuthChallenge.parse(status, .proxy, hdr.value) catch null; } else { transfer._auth_challenge = .{ .status = status, .source = null, .scheme = null, .realm = null }; } diff --git a/src/network/http.zig b/src/network/http.zig index dac76749..2bfabac0 100644 --- a/src/network/http.zig +++ b/src/network/http.zig @@ -413,6 +413,24 @@ pub const Connection = struct { return @intCast(count); } + pub fn getConnectHeader(self: *const Connection, name: [:0]const u8, index: usize) ?HeaderValue { + var hdr: ?*libcurl.CurlHeader = null; + libcurl.curl_easy_header(self._easy, name, index, .connect, -1, &hdr) catch |err| { + // ErrorHeader includes OutOfMemory — rare but real errors from curl internals. + // Logged and returned as null since callers don't expect errors. + log.err(.http, "get response header", .{ + .name = name, + .err = err, + }); + return null; + }; + const h = hdr orelse return null; + return .{ + .amount = h.amount, + .value = std.mem.span(h.value), + }; + } + pub fn getResponseHeader(self: *const Connection, name: [:0]const u8, index: usize) ?HeaderValue { var hdr: ?*libcurl.CurlHeader = null; libcurl.curl_easy_header(self._easy, name, index, .header, -1, &hdr) catch |err| {