| ... | ... | @@ -3,9 +3,9 @@ const string = []const u8; |
| 3 | 3 | |
| 4 | 4 | pub const Jar = std.StringHashMap(string); |
| 5 | 5 | |
| 6 | | pub fn parse(alloc: std.mem.Allocator, headers: std.http.Headers) !Jar { |
| 6 | pub fn parse(alloc: std.mem.Allocator, cookie_str: ?string) !Jar { |
| 7 | 7 | var map = Jar.init(alloc); |
| 8 | | const h = headers.getFirstValue("cookie") orelse return map; |
| 8 | const h = cookie_str orelse return map; |
| 9 | 9 | var iter = std.mem.split(u8, h, "; "); |
| 10 | 10 | while (iter.next()) |item| { |
| 11 | 11 | const i = std.mem.indexOfScalar(u8, item, '='); |
| ... | ... | @@ -19,6 +19,6 @@ pub fn parse(alloc: std.mem.Allocator, headers: std.http.Headers) !Jar { |
| 19 | 19 | return map; |
| 20 | 20 | } |
| 21 | 21 | |
| 22 | | pub fn delete(response: *std.http.Server.Response, comptime name: string) !void { |
| 23 | | try response.headers.append("Set-Cookie", name ++ "=; path=/; expires=Thu, 01 Jan 1970 00:00:00 GMT"); |
| 22 | pub fn delete_string(comptime name: string) string { |
| 23 | return name ++ "=; path=/; expires=Thu, 01 Jan 1970 00:00:00 GMT"; |
| 24 | 24 | } |