mirror of
https://github.com/lightpanda-io/browser.git
synced 2026-03-30 17:18:57 +00:00
http: add connect headers to auth challenge detection
This commit is contained in:
@@ -1270,8 +1270,12 @@ pub const Transfer = struct {
|
|||||||
|
|
||||||
if (conn.getResponseHeader("WWW-Authenticate", 0)) |hdr| {
|
if (conn.getResponseHeader("WWW-Authenticate", 0)) |hdr| {
|
||||||
transfer._auth_challenge = http.AuthChallenge.parse(status, .server, hdr.value) catch null;
|
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| {
|
} else if (conn.getResponseHeader("Proxy-Authenticate", 0)) |hdr| {
|
||||||
transfer._auth_challenge = http.AuthChallenge.parse(status, .proxy, hdr.value) catch null;
|
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 {
|
} else {
|
||||||
transfer._auth_challenge = .{ .status = status, .source = null, .scheme = null, .realm = null };
|
transfer._auth_challenge = .{ .status = status, .source = null, .scheme = null, .realm = null };
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -413,6 +413,24 @@ pub const Connection = struct {
|
|||||||
return @intCast(count);
|
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 {
|
pub fn getResponseHeader(self: *const Connection, name: [:0]const u8, index: usize) ?HeaderValue {
|
||||||
var hdr: ?*libcurl.CurlHeader = null;
|
var hdr: ?*libcurl.CurlHeader = null;
|
||||||
libcurl.curl_easy_header(self._easy, name, index, .header, -1, &hdr) catch |err| {
|
libcurl.curl_easy_header(self._easy, name, index, .header, -1, &hdr) catch |err| {
|
||||||
|
|||||||
Reference in New Issue
Block a user