File tree Expand file tree Collapse file tree 2 files changed +22
-0
lines changed Expand file tree Collapse file tree 2 files changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -319,6 +319,7 @@ pub fn BrowserContext(comptime CDP_T: type) type {
319
319
320
320
inspector : Inspector ,
321
321
isolated_world : ? IsolatedWorld ,
322
+ http_proxy_before : ?? std.Uri = null ,
322
323
323
324
const Self = @This ();
324
325
@@ -373,6 +374,8 @@ pub fn BrowserContext(comptime CDP_T: type) type {
373
374
self .node_registry .deinit ();
374
375
self .node_search_list .deinit ();
375
376
self .cdp .browser .notification .unregisterAll (self );
377
+
378
+ if (self .http_proxy_before ) | prev_proxy | self .cdp .browser .http_client .http_proxy = prev_proxy ;
376
379
}
377
380
378
381
pub fn reset (self : * Self ) void {
Original file line number Diff line number Diff line change @@ -66,11 +66,30 @@ fn getBrowserContexts(cmd: anytype) !void {
66
66
}
67
67
68
68
fn createBrowserContext (cmd : anytype ) ! void {
69
+ const params = try cmd .params (struct {
70
+ disposeOnDetach : bool = false ,
71
+ proxyServer : ? []const u8 = null ,
72
+ proxyBypassList : ? []const u8 = null ,
73
+ originsWithUniversalNetworkAccess : ? []const []const u8 = null ,
74
+ });
75
+ if (params ) | p | {
76
+ if (p .disposeOnDetach or p .proxyBypassList != null or p .originsWithUniversalNetworkAccess != null ) std .debug .print ("Target.createBrowserContext: Not implemented param set\n " , .{});
77
+ }
78
+
69
79
const bc = cmd .createBrowserContext () catch | err | switch (err ) {
70
80
error .AlreadyExists = > return cmd .sendError (-32000 , "Cannot have more than one browser context at a time" ),
71
81
else = > return err ,
72
82
};
73
83
84
+ if (params ) | p | {
85
+ if (p .proxyServer ) | proxy | {
86
+ // For now the http client is not in the browser context so we assume there is just 1.
87
+ bc .http_proxy_before = cmd .cdp .browser .http_client .http_proxy ;
88
+ const proxy_cp = try cmd .cdp .browser .http_client .allocator .dupe (u8 , proxy );
89
+ cmd .cdp .browser .http_client .http_proxy = try std .Uri .parse (proxy_cp );
90
+ }
91
+ }
92
+
74
93
return cmd .sendResult (.{
75
94
.browserContextId = bc .id ,
76
95
}, .{});
You can’t perform that action at this time.
0 commit comments