mirror of
https://github.com/lightpanda-io/browser.git
synced 2025-10-30 15:41:48 +00:00
Merge pull request #960 from lightpanda-io/auth-challenge
Some checks failed
e2e-test / zig build release (push) Has been cancelled
e2e-test / demo-scripts (push) Has been cancelled
e2e-test / cdp-and-hyperfine-bench (push) Has been cancelled
e2e-test / perf-fmt (push) Has been cancelled
zig-test / zig build dev (push) Has been cancelled
zig-test / browser fetch (push) Has been cancelled
zig-test / zig test (push) Has been cancelled
zig-test / perf-fmt (push) Has been cancelled
Some checks failed
e2e-test / zig build release (push) Has been cancelled
e2e-test / demo-scripts (push) Has been cancelled
e2e-test / cdp-and-hyperfine-bench (push) Has been cancelled
e2e-test / perf-fmt (push) Has been cancelled
zig-test / zig build dev (push) Has been cancelled
zig-test / browser fetch (push) Has been cancelled
zig-test / zig test (push) Has been cancelled
zig-test / perf-fmt (push) Has been cancelled
auth required interception
This commit is contained in:
@@ -474,12 +474,16 @@ pub fn BrowserContext(comptime CDP_T: type) type {
|
||||
self.cdp.browser.notification.unregister(.http_response_header_done, self);
|
||||
}
|
||||
|
||||
pub fn fetchEnable(self: *Self) !void {
|
||||
pub fn fetchEnable(self: *Self, authRequests: bool) !void {
|
||||
try self.cdp.browser.notification.register(.http_request_intercept, self, onHttpRequestIntercept);
|
||||
if (authRequests) {
|
||||
try self.cdp.browser.notification.register(.http_request_auth_required, self, onHttpRequestAuthRequired);
|
||||
}
|
||||
}
|
||||
|
||||
pub fn fetchDisable(self: *Self) void {
|
||||
self.cdp.browser.notification.unregister(.http_request_intercept, self);
|
||||
self.cdp.browser.notification.unregister(.http_request_auth_required, self);
|
||||
}
|
||||
|
||||
pub fn onPageRemove(ctx: *anyopaque, _: Notification.PageRemove) !void {
|
||||
@@ -545,6 +549,12 @@ pub fn BrowserContext(comptime CDP_T: type) type {
|
||||
try gop.value_ptr.appendSlice(arena, try arena.dupe(u8, msg.data));
|
||||
}
|
||||
|
||||
pub fn onHttpRequestAuthRequired(ctx: *anyopaque, data: *const Notification.RequestAuthRequired) !void {
|
||||
const self: *Self = @alignCast(@ptrCast(ctx));
|
||||
defer self.resetNotificationArena();
|
||||
try @import("domains/fetch.zig").requestAuthRequired(self.notification_arena, self, data);
|
||||
}
|
||||
|
||||
fn resetNotificationArena(self: *Self) void {
|
||||
defer _ = self.cdp.notification_arena.reset(.{ .retain_with_limit = 1024 * 64 });
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user