Skip to content

Commit

Permalink
Fix concatCookie to put cookies at the end not the beginning
Browse files Browse the repository at this point in the history
Should replace fix for yesodweb#454
  • Loading branch information
dylex committed Oct 19, 2015
1 parent ca4fb95 commit 4c941c5
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions warp/Network/Wai/Handler/Warp/HTTP2/HPACK.hs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,9 @@ hpackDecodeHeader hdrblk Context{decodeDynamicTable} = do
-- >>> concatCookie [("cookie","a=b"),("foo","bar"),("cookie","c=d"),("cookie","e=f")]
-- [("cookie","a=b; c=d; e=f"),("foo","bar")]
concatCookie :: HeaderList -> HeaderList
concatCookie hdr = case L.partition (\x -> fst x == "cookie") hdr of
([],_) -> hdr
(cookies,others) -> let cookieValue = B.intercalate "; " (map snd cookies)
in ("cookie",cookieValue) : others
concatCookie = collect []
where
collect cookies (("cookie",c):rest) = collect (cookies ++ [c]) rest
collect cookies (h:rest) = h : collect cookies rest
collect [] [] = []
collect cookies [] = [("cookie", B.intercalate "; " cookies)]

0 comments on commit 4c941c5

Please sign in to comment.