Skip to content

Commit c1319d1

Browse files
committed
add proper resourceType
1 parent 0122360 commit c1319d1

File tree

5 files changed

+16
-1
lines changed

5 files changed

+16
-1
lines changed

src/browser/ScriptManager.zig

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,7 @@ pub fn addFromElement(self: *ScriptManager, element: *parser.Element) !void {
238238
.method = .GET,
239239
.headers = headers,
240240
.cookie_jar = page.cookie_jar,
241+
.resource_type = .script,
241242
.start_callback = if (log.enabled(.http, .debug)) startCallback else null,
242243
.header_done_callback = headerCallback,
243244
.data_callback = dataCallback,
@@ -306,6 +307,7 @@ pub fn blockingGet(self: *ScriptManager, url: [:0]const u8) !BlockingResult {
306307
.headers = headers,
307308
.cookie_jar = self.page.cookie_jar,
308309
.ctx = &blocking,
310+
.resource_type = .script,
309311
.start_callback = if (log.enabled(.http, .debug)) Blocking.startCallback else null,
310312
.header_done_callback = Blocking.headerCallback,
311313
.data_callback = Blocking.dataCallback,

src/browser/page.zig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -516,6 +516,7 @@ pub const Page = struct {
516516
.headers = headers,
517517
.body = opts.body,
518518
.cookie_jar = self.cookie_jar,
519+
.resource_type = .document,
519520
.header_done_callback = pageHeaderDoneCallback,
520521
.data_callback = pageDataCallback,
521522
.done_callback = pageDoneCallback,

src/browser/xhr/xhr.zig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -383,6 +383,7 @@ pub const XMLHttpRequest = struct {
383383
.headers = headers,
384384
.body = self.request_body,
385385
.cookie_jar = page.cookie_jar,
386+
.resource_type = .xhr,
386387
.start_callback = httpStartCallback,
387388
.header_callback = httpHeaderCallback,
388389
.header_done_callback = httpHeaderDoneCallback,

src/cdp/domains/fetch.zig

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,11 @@ pub fn requestIntercept(arena: Allocator, bc: anytype, intercept: *const Notific
166166
.requestId = try std.fmt.allocPrint(arena, "INTERCEPT-{d}", .{transfer.id}),
167167
.request = network.TransferAsRequestWriter.init(transfer),
168168
.frameId = target_id,
169-
.resourceType = ResourceType.Document, // TODO!
169+
.resourceType = switch (transfer.req.resource_type) {
170+
.script => "Script",
171+
.xhr => "XHR",
172+
.document => "Document",
173+
},
170174
.networkId = try std.fmt.allocPrint(arena, "REQ-{d}", .{transfer.id}),
171175
}, .{ .session_id = session_id });
172176

src/http/Client.zig

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -529,6 +529,7 @@ pub const Request = struct {
529529
headers: Headers,
530530
body: ?[]const u8 = null,
531531
cookie_jar: *storage.CookieJar,
532+
resource_type: ResourceType,
532533

533534
// arbitrary data that can be associated with this request
534535
ctx: *anyopaque = undefined,
@@ -539,6 +540,12 @@ pub const Request = struct {
539540
data_callback: *const fn (transfer: *Transfer, data: []const u8) anyerror!void,
540541
done_callback: *const fn (ctx: *anyopaque) anyerror!void,
541542
error_callback: *const fn (ctx: *anyopaque, err: anyerror) void,
543+
544+
const ResourceType = enum {
545+
document,
546+
xhr,
547+
script,
548+
};
542549
};
543550

544551
pub const Transfer = struct {

0 commit comments

Comments
 (0)