mirror of
https://github.com/lightpanda-io/browser.git
synced 2025-10-29 07:03:29 +00:00
add proper resourceType
This commit is contained in:
@@ -238,6 +238,7 @@ pub fn addFromElement(self: *ScriptManager, element: *parser.Element) !void {
|
||||
.method = .GET,
|
||||
.headers = headers,
|
||||
.cookie_jar = page.cookie_jar,
|
||||
.resource_type = .script,
|
||||
.start_callback = if (log.enabled(.http, .debug)) startCallback else null,
|
||||
.header_done_callback = headerCallback,
|
||||
.data_callback = dataCallback,
|
||||
@@ -306,6 +307,7 @@ pub fn blockingGet(self: *ScriptManager, url: [:0]const u8) !BlockingResult {
|
||||
.headers = headers,
|
||||
.cookie_jar = self.page.cookie_jar,
|
||||
.ctx = &blocking,
|
||||
.resource_type = .script,
|
||||
.start_callback = if (log.enabled(.http, .debug)) Blocking.startCallback else null,
|
||||
.header_done_callback = Blocking.headerCallback,
|
||||
.data_callback = Blocking.dataCallback,
|
||||
|
||||
@@ -516,6 +516,7 @@ pub const Page = struct {
|
||||
.headers = headers,
|
||||
.body = opts.body,
|
||||
.cookie_jar = self.cookie_jar,
|
||||
.resource_type = .document,
|
||||
.header_done_callback = pageHeaderDoneCallback,
|
||||
.data_callback = pageDataCallback,
|
||||
.done_callback = pageDoneCallback,
|
||||
|
||||
@@ -383,6 +383,7 @@ pub const XMLHttpRequest = struct {
|
||||
.headers = headers,
|
||||
.body = self.request_body,
|
||||
.cookie_jar = page.cookie_jar,
|
||||
.resource_type = .xhr,
|
||||
.start_callback = httpStartCallback,
|
||||
.header_callback = httpHeaderCallback,
|
||||
.header_done_callback = httpHeaderDoneCallback,
|
||||
|
||||
@@ -166,7 +166,11 @@ pub fn requestIntercept(arena: Allocator, bc: anytype, intercept: *const Notific
|
||||
.requestId = try std.fmt.allocPrint(arena, "INTERCEPT-{d}", .{transfer.id}),
|
||||
.request = network.TransferAsRequestWriter.init(transfer),
|
||||
.frameId = target_id,
|
||||
.resourceType = ResourceType.Document, // TODO!
|
||||
.resourceType = switch (transfer.req.resource_type) {
|
||||
.script => "Script",
|
||||
.xhr => "XHR",
|
||||
.document => "Document",
|
||||
},
|
||||
.networkId = try std.fmt.allocPrint(arena, "REQ-{d}", .{transfer.id}),
|
||||
}, .{ .session_id = session_id });
|
||||
|
||||
|
||||
@@ -529,6 +529,7 @@ pub const Request = struct {
|
||||
headers: Headers,
|
||||
body: ?[]const u8 = null,
|
||||
cookie_jar: *storage.CookieJar,
|
||||
resource_type: ResourceType,
|
||||
|
||||
// arbitrary data that can be associated with this request
|
||||
ctx: *anyopaque = undefined,
|
||||
@@ -539,6 +540,12 @@ pub const Request = struct {
|
||||
data_callback: *const fn (transfer: *Transfer, data: []const u8) anyerror!void,
|
||||
done_callback: *const fn (ctx: *anyopaque) anyerror!void,
|
||||
error_callback: *const fn (ctx: *anyopaque, err: anyerror) void,
|
||||
|
||||
const ResourceType = enum {
|
||||
document,
|
||||
xhr,
|
||||
script,
|
||||
};
|
||||
};
|
||||
|
||||
pub const Transfer = struct {
|
||||
|
||||
Reference in New Issue
Block a user