From dcc0b3a5aa0667f37f7e1f6bf44a1c083663ebfa Mon Sep 17 00:00:00 2001 From: Meghan Denny Date: Wed, 31 May 2023 01:18:55 -0700 Subject: [PATCH] use std.http instead of apple_pie --- cookies.zig | 14 +++++--------- zigmod.yml | 1 - 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/cookies.zig b/cookies.zig index f986ae6c638b67a168cac93d1f4ab0da993f7723..d354c8bc93bb45afffd3fbe15e31f3c3e742e61f 100644 --- a/cookies.zig +++ b/cookies.zig @@ -1,16 +1,12 @@ const std = @import("std"); const string = []const u8; -const http = @import("apple_pie"); pub const Jar = std.StringHashMap(string); -pub fn parse(alloc: std.mem.Allocator, headers: http.Request.Headers) !Jar { +pub fn parse(alloc: std.mem.Allocator, headers: std.http.Headers) !Jar { var map = Jar.init(alloc); - // extra check caused by https://github.com/Luukdegram/apple_pie/issues/70 - const h = headers.get("Cookie") orelse headers.get("cookie"); - if (h == null) return map; - - var iter = std.mem.split(u8, h.?, ";"); + const h = headers.getFirstValue("cookie") orelse return map; + var iter = std.mem.split(u8, h, ";"); while (iter.next()) |item| { const i = std.mem.indexOfScalar(u8, item, '='); if (i == null) continue; @@ -23,6 +19,6 @@ pub fn parse(alloc: std.mem.Allocator, headers: http.Request.Headers) !Jar { return map; } -pub fn delete(response: *http.Response, comptime name: string) !void { - try response.headers.put("Set-Cookie", name ++ "=; path=/; expires=Thu, 01 Jan 1970 00:00:00 GMT"); +pub fn delete(response: *std.http.Server.Response, comptime name: string) !void { + try response.headers.append("Set-Cookie", name ++ "=; path=/; expires=Thu, 01 Jan 1970 00:00:00 GMT"); } diff --git a/zigmod.yml b/zigmod.yml index f4aa832a0f8724e8ce3f0afd763f9b4541f965b8..14710afad90617a647716edfbdc5b55cb8ccb05a 100644 --- a/zigmod.yml +++ b/zigmod.yml @@ -3,4 +3,3 @@ name: cookies main: cookies.zig license: MIT dependencies: - - src: git https://github.com/Luukdegram/apple_pie -- 2.54.0