mirror of
https://github.com/lightpanda-io/browser.git
synced 2025-10-29 15:13:28 +00:00
browser context proxyServer
This commit is contained in:
@@ -319,6 +319,7 @@ pub fn BrowserContext(comptime CDP_T: type) type {
|
|||||||
|
|
||||||
inspector: Inspector,
|
inspector: Inspector,
|
||||||
isolated_world: ?IsolatedWorld,
|
isolated_world: ?IsolatedWorld,
|
||||||
|
http_proxy_before: ??std.Uri = null,
|
||||||
|
|
||||||
const Self = @This();
|
const Self = @This();
|
||||||
|
|
||||||
@@ -373,6 +374,8 @@ pub fn BrowserContext(comptime CDP_T: type) type {
|
|||||||
self.node_registry.deinit();
|
self.node_registry.deinit();
|
||||||
self.node_search_list.deinit();
|
self.node_search_list.deinit();
|
||||||
self.cdp.browser.notification.unregisterAll(self);
|
self.cdp.browser.notification.unregisterAll(self);
|
||||||
|
|
||||||
|
if (self.http_proxy_before) |prev_proxy| self.cdp.browser.http_client.http_proxy = prev_proxy;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn reset(self: *Self) void {
|
pub fn reset(self: *Self) void {
|
||||||
|
|||||||
@@ -66,11 +66,30 @@ fn getBrowserContexts(cmd: anytype) !void {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn createBrowserContext(cmd: anytype) !void {
|
fn createBrowserContext(cmd: anytype) !void {
|
||||||
|
const params = try cmd.params(struct {
|
||||||
|
disposeOnDetach: bool = false,
|
||||||
|
proxyServer: ?[]const u8 = null,
|
||||||
|
proxyBypassList: ?[]const u8 = null,
|
||||||
|
originsWithUniversalNetworkAccess: ?[]const []const u8 = null,
|
||||||
|
});
|
||||||
|
if (params) |p| {
|
||||||
|
if (p.disposeOnDetach or p.proxyBypassList != null or p.originsWithUniversalNetworkAccess != null) std.debug.print("Target.createBrowserContext: Not implemented param set\n", .{});
|
||||||
|
}
|
||||||
|
|
||||||
const bc = cmd.createBrowserContext() catch |err| switch (err) {
|
const bc = cmd.createBrowserContext() catch |err| switch (err) {
|
||||||
error.AlreadyExists => return cmd.sendError(-32000, "Cannot have more than one browser context at a time"),
|
error.AlreadyExists => return cmd.sendError(-32000, "Cannot have more than one browser context at a time"),
|
||||||
else => return err,
|
else => return err,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if (params) |p| {
|
||||||
|
if (p.proxyServer) |proxy| {
|
||||||
|
// For now the http client is not in the browser context so we assume there is just 1.
|
||||||
|
bc.http_proxy_before = cmd.cdp.browser.http_client.http_proxy;
|
||||||
|
const proxy_cp = try cmd.cdp.browser.http_client.allocator.dupe(u8, proxy);
|
||||||
|
cmd.cdp.browser.http_client.http_proxy = try std.Uri.parse(proxy_cp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return cmd.sendResult(.{
|
return cmd.sendResult(.{
|
||||||
.browserContextId = bc.id,
|
.browserContextId = bc.id,
|
||||||
}, .{});
|
}, .{});
|
||||||
|
|||||||
Reference in New Issue
Block a user