1
0
Fork 0
mirror of https://github.com/zigzap/zap.git synced 2025-10-20 15:14:08 +00:00

Compare commits

...

2 commits

Author SHA1 Message Date
Rene Schallner
a953fc5969
Merge pull request #172 from pollend/feature/cookie-add-partition
feat: add parition support for cookies in facil.io
2025-08-07 10:31:01 +02:00
Michael Pollind
6174c3e5e0 feat: add parition support for cookies in facil.io
Signed-off-by: Michael Pollind <mpollind@gmail.com>
2025-08-06 21:12:08 -07:00
4 changed files with 8 additions and 0 deletions

View file

@ -320,6 +320,9 @@ int http_set_cookie(http_s *h, http_cookie_args_s cookie) {
if (cookie.secure) { if (cookie.secure) {
fiobj_str_write(c, "secure;", 7); fiobj_str_write(c, "secure;", 7);
} }
if(cookie.partitioned) {
fiobj_str_write(c, "Partitioned;", 12);
}
set_header_add(h->private_data.out_headers, HTTP_HEADER_SET_COOKIE, c); set_header_add(h->private_data.out_headers, HTTP_HEADER_SET_COOKIE, c);
return 0; return 0;
} }

View file

@ -153,6 +153,8 @@ typedef struct {
unsigned secure : 1; unsigned secure : 1;
/** Limit cookie to HTTP (intended to prevent javascript access/hijacking).*/ /** Limit cookie to HTTP (intended to prevent javascript access/hijacking).*/
unsigned http_only : 1; unsigned http_only : 1;
/** Partitioned storage, with a separate cookie jar per top-level site */
unsigned partitioned: 1;
} http_cookie_args_s; } http_cookie_args_s;
/** /**

View file

@ -116,6 +116,7 @@ pub const http_cookie_args_s = extern struct {
max_age: c_int, max_age: c_int,
secure: c_uint, secure: c_uint,
http_only: c_uint, http_only: c_uint,
partitioned: c_uint,
}; };
pub const struct_fio_str_info_s = extern struct { pub const struct_fio_str_info_s = extern struct {

View file

@ -273,6 +273,7 @@ pub const CookieArgs = struct {
max_age_s: c_int = 0, max_age_s: c_int = 0,
secure: bool = true, secure: bool = true,
http_only: bool = true, http_only: bool = true,
partitioned: bool = false,
}; };
path: ?[]const u8, path: ?[]const u8,
@ -683,6 +684,7 @@ pub fn setCookie(self: *const Request, args: CookieArgs) HttpError!void {
.max_age = args.max_age_s, .max_age = args.max_age_s,
.secure = if (args.secure) 1 else 0, .secure = if (args.secure) 1 else 0,
.http_only = if (args.http_only) 1 else 0, .http_only = if (args.http_only) 1 else 0,
.partitioned = if (args.partitioned) 1 else 0,
}; };
// TODO WAT? // TODO WAT?