From 58a0dd900fc1132ab8d5b13e04ae81374496960e Mon Sep 17 00:00:00 2001 From: jaina heartles Date: Thu, 17 Nov 2022 19:48:25 -0800 Subject: [PATCH] Fix print call --- src/http/headers.zig | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/http/headers.zig b/src/http/headers.zig index f459ed6..a0bebea 100644 --- a/src/http/headers.zig +++ b/src/http/headers.zig @@ -133,20 +133,21 @@ pub const Fields = struct { }; pub fn setCookie(self: *Fields, name: []const u8, value: []const u8, opt: CookieOptions) !void { - const cookie = try std.fmt.printAlloc( + const cookie = try std.fmt.allocPrint( self.allocator, - "{s}={s}{s}{s}{s}", + "{s}={s}{s}{s}{s}{s}", .{ name, value, if (opt.Secure) "; Secure" else "", if (opt.HttpOnly) "; HttpOnly" else "", - if (opt.SameSite) |same_site| "; SameSite=" ++ @tagName(same_site) else "", + if (opt.SameSite) |_| "; SameSite=" else "", + if (opt.SameSite) |same_site| @tagName(same_site) else "", }, ); defer self.allocator.free(cookie); // TODO: reduce unnecessary allocations - self.append("Set-Cookie", cookie); + try self.append("Set-Cookie", cookie); } };