mirror of
https://github.com/lightpanda-io/browser.git
synced 2026-03-22 04:34:44 +00:00
Some code-review fixes
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user