Fix SameSite cookies

This commit is contained in:
Nikolay Govorov
2026-03-27 11:16:46 +00:00
parent 5369d25213
commit 9068fe718e
5 changed files with 9 additions and 1 deletions

View File

@@ -382,6 +382,7 @@ fn fetchRobotsThenProcessRequest(self: *Client, robots_url: [:0]const u8, req: R
.blocking = false,
.frame_id = req.frame_id,
.cookie_jar = req.cookie_jar,
.cookie_origin = req.cookie_origin,
.notification = req.notification,
.resource_type = .fetch,
.header_callback = robotsHeaderCallback,
@@ -923,6 +924,7 @@ pub const Request = struct {
headers: http.Headers,
body: ?[]const u8 = null,
cookie_jar: ?*CookieJar,
cookie_origin: [:0]const u8,
resource_type: ResourceType,
credentials: ?[:0]const u8 = null,
notification: *Notification,
@@ -1178,7 +1180,7 @@ pub const Transfer = struct {
var aw: std.Io.Writer.Allocating = .init(self.arena.allocator());
try jar.forRequest(self.req.url, &aw.writer, .{
.is_http = true,
.origin_url = self.req.url,
.origin_url = self.req.cookie_origin,
.is_navigation = self.req.resource_type == .document,
});
const written = aw.written();

View File

@@ -564,6 +564,7 @@ pub fn navigate(self: *Page, request_url: [:0]const u8, opts: NavigateOpts) !voi
.headers = headers,
.body = opts.body,
.cookie_jar = &session.cookie_jar,
.cookie_origin = self.url,
.resource_type = .document,
.notification = self._session.notification,
.header_callback = pageHeaderDoneCallback,

View File

@@ -281,6 +281,7 @@ pub fn addFromElement(self: *ScriptManager, comptime from_parser: bool, script_e
.headers = try self.getHeaders(),
.blocking = is_blocking,
.cookie_jar = &page._session.cookie_jar,
.cookie_origin = page.url,
.resource_type = .script,
.notification = page._session.notification,
.start_callback = if (log.enabled(.http, .debug)) Script.startCallback else null,
@@ -405,6 +406,7 @@ pub fn preloadImport(self: *ScriptManager, url: [:0]const u8, referrer: []const
.frame_id = page._frame_id,
.headers = try self.getHeaders(),
.cookie_jar = &page._session.cookie_jar,
.cookie_origin = page.url,
.resource_type = .script,
.notification = page._session.notification,
.start_callback = if (log.enabled(.http, .debug)) Script.startCallback else null,
@@ -510,6 +512,7 @@ pub fn getAsyncImport(self: *ScriptManager, url: [:0]const u8, cb: ImportAsync.C
.ctx = script,
.resource_type = .script,
.cookie_jar = &page._session.cookie_jar,
.cookie_origin = page.url,
.notification = page._session.notification,
.start_callback = if (log.enabled(.http, .debug)) Script.startCallback else null,
.header_callback = Script.headerCallback,

View File

@@ -95,6 +95,7 @@ pub fn init(input: Input, options: ?InitOpts, page: *Page) !js.Promise {
.headers = headers,
.resource_type = .fetch,
.cookie_jar = &page._session.cookie_jar,
.cookie_origin = page.url,
.notification = page._session.notification,
.start_callback = httpStartCallback,
.header_callback = httpHeaderDoneCallback,

View File

@@ -235,6 +235,7 @@ pub fn send(self: *XMLHttpRequest, body_: ?[]const u8) !void {
.frame_id = page._frame_id,
.body = self._request_body,
.cookie_jar = if (cookie_support) &page._session.cookie_jar else null,
.cookie_origin = page.url,
.resource_type = .xhr,
.notification = page._session.notification,
.start_callback = httpStartCallback,