on master help sign in
Fix concatCookie to put cookies at the end not the beginning

Should replace fix for #454

commit167f354e9d137b3ff17b4c4f8252601202dff2e0 authorDylan Simon <dylan@dylex.net> dateSun 18 Oct 2015, 20:05 (11 years ago) parentb10ce91
1 file changed+6−4
warp/Network/Wai/Handler/Warp/HTTP2/HPACK.hs+6−4
warp/Network/Wai/Handler/Warp/HTTP2/HPACK.hs+6−4
@@ -65,7 +65,9 @@ hpackDecodeHeader hdrblk Context{decodeDynamicTable} = do
6565-- >>> concatCookie [("cookie","a=b"),("foo","bar"),("cookie","c=d"),("cookie","e=f")]
6666-- [("cookie","a=b; c=d; e=f"),("foo","bar")]
6767concatCookie :: HeaderList -> HeaderList
68−concatCookie hdr = case L.partition (\x -> fst x == "cookie") hdr of
69− ([],_) -> hdr
70− (cookies,others) -> let cookieValue = B.intercalate "; " (map snd cookies)
71− in ("cookie",cookieValue) : others
68+concatCookie = collect []
69+ where
70+ collect cookies (("cookie",c):rest) = collect (cookies ++ [c]) rest
71+ collect cookies (h:rest) = h : collect cookies rest
72+ collect [] [] = []
73+ collect cookies [] = [("cookie", B.intercalate "; " cookies)]