-
Notifications
You must be signed in to change notification settings - Fork 2
Description
wai responses with multiple headers with the same key are not preserved when converting them to an Aeson object, because the list of (HeaderName, HeaderValue) pairs goes through a hashmap while generating the response object in API Gateway's preferred format: https://github.com/deckgo/wai-lambda/blob/master/src/Network/Wai/Handler/Lambda.hs#L334
This is problematic for any header that appears multiple times, for example, Set-Cookie and Cookie headers, which are often present multiple times in a response/request.
The lambda payload format singles cookies out for special treatment, putting them in their own top-level "cookies": [] field, not in "headers":{}.
I'm not sure, but I believe the solution is to encode Cookie headers specially for wai requests (pulling them from the lambda "cookies" field and adding them to Wai request headers), and to decode Set-Cookie headers specially for wai responses (filtering Set-Cookie headers from the Wai response and placing those into "cookies" for the lambda response object). At least this is what I'm doing in my wai-lambda fork, and it appears to do the right thing (cookies are set in the browser and accepted by the server for my lambda-hosted servant app).