@@ -64,8 +64,16 @@ hpackDecodeHeader hdrblk Context{decodeDynamicTable} = do
6464-- [("foo","bar")]
6565-- >>> concatCookie [("cookie","a=b"),("foo","bar"),("cookie","c=d"),("cookie","e=f")]
6666-- [("cookie","a=b; c=d; e=f"),("foo","bar")]
67+-- >>> concatCookie [(":pseudo","pseudo"),("cookie","a=b"),("foo","bar"),("cookie","c=d"),("cookie","e=f")]
68+-- [(":pseudo","pseudo"),("cookie","a=b; c=d; e=f"),("foo","bar")]
6769concatCookie :: HeaderList -> HeaderList
6870concatCookie hdr = case L.partition (\x -> fst x == "cookie") hdr of
6971 ([],_) -> hdr
7072 (cookies,others) -> let cookieValue = B.intercalate "; " (map snd cookies)
71− in ("cookie",cookieValue) : others
73+ in insertAfterPseudo ("cookie",cookieValue) others
74+
75+insertAfterPseudo :: Header -> HeaderList -> HeaderList
76+insertAfterPseudo x [] = [x]
77+insertAfterPseudo x yys@(y:ys)
78+ | isPseudo (fst y) = y : insertAfterPseudo x ys
79+ | otherwise = x : yys