mirror of
https://github.com/lightpanda-io/browser.git
synced 2026-08-02 18:59:36 -04:00
cdp: complete Network event payloads
Add required timestamp, type, request, response, and timing fields so strict CDP clients can deserialize emitted events.
This commit is contained in:
@@ -328,6 +328,7 @@ pub fn httpRequestFail(bc: *CDP.BrowserContext, msg: *const Notification.Request
|
||||
// We're missing a bunch of fields, but, for now, this seems like enough
|
||||
try bc.cdp.sendEvent("Network.loadingFailed", .{
|
||||
.requestId = &id.toRequestId(msg.transfer),
|
||||
.timestamp = timestamp(.monotonic),
|
||||
// Seems to be what chrome answers with. I assume it depends on the type of error?
|
||||
.type = "Ping",
|
||||
.errorText = msg.err,
|
||||
@@ -382,6 +383,8 @@ pub fn httpResponseHeaderDone(arena: Allocator, bc: *CDP.BrowserContext, msg: *c
|
||||
.frameId = &id.toFrameId(req.frame_id),
|
||||
.requestId = &id.toRequestId(transfer),
|
||||
.loaderId = &id.toLoaderId(req.loader_id),
|
||||
.timestamp = timestamp(.monotonic),
|
||||
.type = req.resource_type.string(),
|
||||
.response = ResponseWriter.init(arena, msg.transfer),
|
||||
.hasExtraInfo = false, // TODO change after adding Network.responseReceivedExtraInfo
|
||||
}, .{ .session_id = session_id });
|
||||
@@ -393,6 +396,7 @@ pub fn httpRequestDone(bc: *CDP.BrowserContext, msg: *const Notification.Request
|
||||
const session_id = bc.session_id orelse return;
|
||||
try bc.cdp.sendEvent("Network.loadingFinished", .{
|
||||
.requestId = &id.toRequestId(msg.transfer),
|
||||
.timestamp = timestamp(.monotonic),
|
||||
.encodedDataLength = msg.content_length,
|
||||
}, .{ .session_id = session_id });
|
||||
}
|
||||
@@ -447,6 +451,16 @@ pub const RequestWriter = struct {
|
||||
try jws.write(request.body != null);
|
||||
}
|
||||
|
||||
{
|
||||
try jws.objectField("initialPriority");
|
||||
try jws.write("High");
|
||||
}
|
||||
|
||||
{
|
||||
try jws.objectField("referrerPolicy");
|
||||
try jws.write("strict-origin-when-cross-origin");
|
||||
}
|
||||
|
||||
{
|
||||
try jws.objectField("headers");
|
||||
try jws.beginObject();
|
||||
@@ -516,6 +530,17 @@ const ResponseWriter = struct {
|
||||
try jws.write(transfer._from_cache);
|
||||
}
|
||||
|
||||
{
|
||||
try jws.objectField("connectionReused");
|
||||
try jws.write(false);
|
||||
try jws.objectField("connectionId");
|
||||
try jws.write(0);
|
||||
try jws.objectField("encodedDataLength");
|
||||
try jws.write(transfer._cdp_content_length);
|
||||
try jws.objectField("securityState");
|
||||
try jws.write("unknown");
|
||||
}
|
||||
|
||||
{
|
||||
try jws.objectField("timing");
|
||||
try jws.write(.{
|
||||
@@ -533,6 +558,12 @@ const ResponseWriter = struct {
|
||||
.sendStart = -1,
|
||||
.sslEnd = -1,
|
||||
.sslStart = -1,
|
||||
.workerStart = -1,
|
||||
.workerReady = -1,
|
||||
.workerFetchStart = -1,
|
||||
.workerRespondWithSettled = -1,
|
||||
.pushStart = -1,
|
||||
.pushEnd = -1,
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user