Use per-cdp connection HttpClient

This commit is contained in:
Nikolay Govorov
2026-02-17 12:37:44 +00:00
parent fbe65cd542
commit 9296c10ca4
9 changed files with 82 additions and 50 deletions

View File

@@ -28,6 +28,7 @@ const js = @import("../browser/js/js.zig");
const App = @import("../App.zig");
const Browser = @import("../browser/Browser.zig");
const Session = @import("../browser/Session.zig");
const HttpClient = @import("../http/Client.zig");
const Page = @import("../browser/Page.zig");
const Incrementing = @import("../id.zig").Incrementing;
const Notification = @import("../Notification.zig");
@@ -84,10 +85,11 @@ pub fn CDPT(comptime TypeProvider: type) type {
const Self = @This();
pub fn init(app: *App, client: TypeProvider.Client) !Self {
pub fn init(app: *App, http_client: *HttpClient, client: TypeProvider.Client) !Self {
const allocator = app.allocator;
const browser = try Browser.init(app, .{
.env = .{ .with_inspector = true },
.http_client = http_client,
});
errdefer browser.deinit();

View File

@@ -85,7 +85,7 @@ const TestContext = struct {
self.client = Client.init(self.arena.allocator());
// Don't use the arena here. We want to detect leaks in CDP.
// The arena is only for test-specific stuff
self.cdp_ = TestCDP.init(base.test_app, &self.client.?) catch unreachable;
self.cdp_ = TestCDP.init(base.test_app, base.test_http, &self.client.?) catch unreachable;
}
return &self.cdp_.?;
}