Merge pull request #1569 from egrs/cdp-cookie-size

add cookie size to CDP response
This commit is contained in:
Pierre Tachoire
2026-02-17 17:57:47 +01:00
committed by GitHub
2 changed files with 7 additions and 5 deletions

View File

@@ -502,7 +502,7 @@ test "cdp.Network: cookies" {
}); });
try ctx.expectSentResult(.{ try ctx.expectSentResult(.{
.cookies = &[_]ResCookie{ .cookies = &[_]ResCookie{
.{ .name = "test3", .value = "value3", .domain = "car.example.com", .path = "/", .secure = true }, // No Pancakes! .{ .name = "test3", .value = "value3", .domain = "car.example.com", .path = "/", .size = 11, .secure = true }, // No Pancakes!
}, },
}, .{ .id = 6 }); }, .{ .id = 6 });
@@ -519,7 +519,7 @@ test "cdp.Network: cookies" {
.params = .{ .browserContextId = "BID-S" }, .params = .{ .browserContextId = "BID-S" },
}); });
// Just the untouched test4 should be in the result // Just the untouched test4 should be in the result
try ctx.expectSentResult(.{ .cookies = &[_]ResCookie{.{ .name = "test4", .value = "value4", .domain = ".example.com", .path = "/mango" }} }, .{ .id = 8 }); try ctx.expectSentResult(.{ .cookies = &[_]ResCookie{.{ .name = "test4", .value = "value4", .domain = ".example.com", .path = "/mango", .size = 11 }} }, .{ .id = 8 });
// Empty after clearBrowserCookies // Empty after clearBrowserCookies
try ctx.processMessage(.{ try ctx.processMessage(.{

View File

@@ -209,7 +209,8 @@ pub fn writeCookie(cookie: *const Cookie, w: anytype) !void {
try w.objectField("expires"); try w.objectField("expires");
try w.write(cookie.expires orelse -1); try w.write(cookie.expires orelse -1);
// TODO size try w.objectField("size");
try w.write(cookie.name.len + cookie.value.len);
try w.objectField("httpOnly"); try w.objectField("httpOnly");
try w.write(cookie.http_only); try w.write(cookie.http_only);
@@ -267,8 +268,8 @@ test "cdp.Storage: cookies" {
}); });
try ctx.expectSentResult(.{ try ctx.expectSentResult(.{
.cookies = &[_]ResCookie{ .cookies = &[_]ResCookie{
.{ .name = "test", .value = "value", .domain = ".example.com", .path = "/mango" }, .{ .name = "test", .value = "value", .domain = ".example.com", .path = "/mango", .size = 9 },
.{ .name = "test2", .value = "value2", .domain = "car.example.com", .path = "/", .secure = true }, // No Pancakes! .{ .name = "test2", .value = "value2", .domain = "car.example.com", .path = "/", .size = 11, .secure = true }, // No Pancakes!
}, },
}, .{ .id = 5 }); }, .{ .id = 5 });
@@ -293,6 +294,7 @@ pub const ResCookie = struct {
domain: []const u8, domain: []const u8,
path: []const u8 = "/", path: []const u8 = "/",
expires: f64 = -1, expires: f64 = -1,
size: usize = 0,
httpOnly: bool = false, httpOnly: bool = false,
secure: bool = false, secure: bool = false,
sameSite: []const u8 = "None", sameSite: []const u8 = "None",