|
|
|
@ -6,6 +6,7 @@ pub const Cookie = struct {
|
|
|
|
|
value: []const u8,
|
|
|
|
|
path: []const u8 = "/",
|
|
|
|
|
domain: []const u8 = "",
|
|
|
|
|
/// Indicates the number of seconds until the cookie expires.
|
|
|
|
|
maxAge: i64 = 0,
|
|
|
|
|
secure: bool = true,
|
|
|
|
|
httpOnly: bool = true,
|
|
|
|
@ -16,7 +17,7 @@ pub const Cookie = struct {
|
|
|
|
|
defer allocator.free(domain);
|
|
|
|
|
const secure = if (self.secure) "Secure; " else "";
|
|
|
|
|
const httpOnly = if (self.httpOnly) "HttpOnly; " else "";
|
|
|
|
|
return try std.fmt.allocPrint(allocator, "Set-Cookie: {s}={s}; {s}Max-Age={}; {s}{s}{s}\n", .{ self.name, self.value, domain, self.maxAge, secure, httpOnly, getSameSite(&self) });
|
|
|
|
|
return try std.fmt.allocPrint(allocator, "Set-Cookie: {s}={s}; Path={s}; {s}Max-Age={}; {s}{s}{s}\n", .{ self.name, self.value, self.path, domain, self.maxAge, secure, httpOnly, getSameSite(&self) });
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|