Some code-review fixes

This commit is contained in:
Nikolay Govorov
2026-03-10 02:49:15 +00:00
parent 8f960ab0f7
commit 2b0c223425
3 changed files with 12 additions and 15 deletions

View File

@@ -36,9 +36,10 @@ const ArenaAllocator = std.heap.ArenaAllocator;
const IS_DEBUG = builtin.mode == .Debug;
const Method = Net.Method;
const ResponseHead = Net.ResponseHead;
const HeaderIterator = Net.HeaderIterator;
pub const Method = Net.Method;
pub const Headers = Net.Headers;
pub const ResponseHead = Net.ResponseHead;
pub const HeaderIterator = Net.HeaderIterator;
// This is loosely tied to a browser Page. Loading all the <scripts>, doing
// XHR requests, and loading imports all happens through here. Sine the app

View File

@@ -62,7 +62,6 @@ const PageTransitionEvent = @import("webapi/event/PageTransitionEvent.zig");
const NavigationKind = @import("webapi/navigation/root.zig").NavigationKind;
const KeyboardEvent = @import("webapi/event/KeyboardEvent.zig");
const Net = @import("../network/http.zig");
const HttpClient = @import("HttpClient.zig");
const ArenaPool = App.ArenaPool;
@@ -396,7 +395,7 @@ pub fn getOrigin(self: *Page, allocator: Allocator) !?[]const u8 {
// Add comon headers for a request:
// * cookies
// * referer
pub fn headersForRequest(self: *Page, temp: Allocator, url: [:0]const u8, headers: *Net.Headers) !void {
pub fn headersForRequest(self: *Page, temp: Allocator, url: [:0]const u8, headers: *HttpClient.Headers) !void {
try self.requestCookie(.{}).headersForRequest(temp, url, headers);
// Build the referer
@@ -3052,7 +3051,7 @@ pub const NavigateReason = enum {
pub const NavigateOpts = struct {
cdp_id: ?i64 = null,
reason: NavigateReason = .address_bar,
method: Net.Method = .GET,
method: HttpClient.Method = .GET,
body: ?[]const u8 = null,
header: ?[:0]const u8 = null,
force: bool = false,
@@ -3062,7 +3061,7 @@ pub const NavigateOpts = struct {
pub const NavigatedOpts = struct {
cdp_id: ?i64 = null,
reason: NavigateReason = .address_bar,
method: Net.Method = .GET,
method: HttpClient.Method = .GET,
};
const NavigationType = enum {

View File

@@ -61,12 +61,9 @@ fn globalDeinit() void {
libcurl.curl_global_cleanup();
}
var global_init_once = std.once(globalInit);
var global_deinit_once = std.once(globalDeinit);
pub fn init(allocator: Allocator, config: *const Config) !Runtime {
global_init_once.call();
errdefer global_deinit_once.call();
globalInit();
errdefer globalDeinit();
const pipe = try posix.pipe2(.{ .NONBLOCK = true, .CLOEXEC = true });
@@ -107,14 +104,14 @@ pub fn deinit(self: *Runtime) void {
self.allocator.free(data[0..ca_blob.len]);
}
global_deinit_once.call();
globalDeinit();
}
pub fn bind(
self: *Runtime,
address: net.Address,
ctx: *anyopaque,
onAccept: *const fn (ctx: *anyopaque, socket: posix.socket_t) void,
on_accept: *const fn (ctx: *anyopaque, socket: posix.socket_t) void,
) !void {
const flags = posix.SOCK.STREAM | posix.SOCK.CLOEXEC | posix.SOCK.NONBLOCK;
const listener = try posix.socket(address.any.family, flags, posix.IPPROTO.TCP);
@@ -133,7 +130,7 @@ pub fn bind(
self.listener = .{
.socket = listener,
.ctx = ctx,
.onAccept = onAccept,
.onAccept = on_accept,
};
self.pollfds[1] = .{
.fd = listener,