replace zig-js-runtime

This commit is contained in:
Karl Seguin
2025-04-02 10:30:59 +08:00
parent 25dcae7648
commit b8d7744563
88 changed files with 5933 additions and 4124 deletions

View File

@@ -27,9 +27,8 @@ const MemoryPool = std.heap.MemoryPool;
const ArenaAllocator = std.heap.ArenaAllocator;
const tls = @import("tls");
const jsruntime = @import("jsruntime");
const IO = jsruntime.IO;
const Loop = jsruntime.Loop;
const IO = @import("../runtime/loop.zig").IO;
const Loop = @import("../runtime/loop.zig").Loop;
const log = std.log.scoped(.http_client);
@@ -53,7 +52,7 @@ pub const Client = struct {
};
pub fn init(allocator: Allocator, max_concurrent: usize, opts: Opts) !Client {
var root_ca = try tls.config.CertBundle.fromSystem(allocator);
var root_ca: tls.config.CertBundle = if (builtin.is_test) .{} else try tls.config.CertBundle.fromSystem(allocator);
errdefer root_ca.deinit(allocator);
const state_pool = try StatePool.init(allocator, max_concurrent);
@@ -69,7 +68,9 @@ pub const Client = struct {
pub fn deinit(self: *Client) void {
const allocator = self.allocator;
self.root_ca.deinit(allocator);
if (builtin.is_test == false) {
self.root_ca.deinit(allocator);
}
self.state_pool.deinit(allocator);
}
@@ -1907,7 +1908,7 @@ test "HttpClient: sync GET redirect" {
}
test "HttpClient: async connect error" {
var loop = try jsruntime.Loop.init(testing.allocator);
var loop = try Loop.init(testing.allocator);
defer loop.deinit();
const Handler = struct {
@@ -2193,7 +2194,7 @@ const TestResponse = struct {
};
const CaptureHandler = struct {
loop: jsruntime.Loop,
loop: Loop,
reset: Thread.ResetEvent,
response: TestResponse,
@@ -2201,7 +2202,7 @@ const CaptureHandler = struct {
return .{
.reset = .{},
.response = TestResponse.init(),
.loop = try jsruntime.Loop.init(testing.allocator),
.loop = try Loop.init(testing.allocator),
};
}