Skip to content

Commit ccc1e24

Browse files
committed
clearRetainingCapacity
1 parent 21337c5 commit ccc1e24

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

src/browser/storage/cookie.zig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ pub const Jar = struct {
3232
self.cookies.deinit(self.allocator);
3333
}
3434

35-
pub fn clear(self: *Jar) void {
35+
pub fn clearRetainingCapacity(self: *Jar) void {
3636
for (self.cookies.items) |c| {
3737
c.deinit();
3838
}

src/cdp/domains/network.zig

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ pub fn processMessage(cmd: anytype) !void {
2929
setCacheDisabled,
3030
setExtraHTTPHeaders,
3131
deleteCookies,
32+
clearBrowserCookies,
3233
setCookie,
3334
setCookies,
3435
}, cmd.input.action) orelse return error.UnknownMethod;
@@ -39,6 +40,7 @@ pub fn processMessage(cmd: anytype) !void {
3940
.setCacheDisabled => return cmd.sendResult(null, .{}),
4041
.setExtraHTTPHeaders => return setExtraHTTPHeaders(cmd),
4142
.deleteCookies => return deleteCookies(cmd),
43+
.clearBrowserCookies => return clearBrowserCookies(cmd),
4244
.setCookie => return setCookie(cmd),
4345
.setCookies => return setCookies(cmd),
4446
}
@@ -123,6 +125,15 @@ fn deleteCookies(cmd: anytype) !void {
123125
return cmd.sendResult(null, .{});
124126
}
125127

128+
fn clearBrowserCookies(cmd: anytype) !void {
129+
_ = (try cmd.params(struct {})) orelse return error.InvalidParams;
130+
131+
const bc = cmd.browser_context orelse return error.BrowserContextNotLoaded;
132+
bc.session.cookie_jar.clearRetainingCapacity();
133+
134+
return cmd.sendResult(null, .{});
135+
}
136+
126137
const SameSite = enum {
127138
Strict,
128139
Lax,

0 commit comments

Comments
 (0)