xp-forge / lambda-ws

AWS Lambda Webservices for the XP Framework
1 stars 0 forks source link

Return cookies in multiValueHeaders #2

Closed thekid closed 3 years ago

thekid commented 3 years ago

Quoting RFC 6265:

Origin servers SHOULD NOT fold multiple Set-Cookie header fields into a single header field. The usual mechanism for folding HTTP headers fields (i.e., as defined in [RFC2616]) might change the semantics of the Set-Cookie header field because the %x2C (",") character is used by Set-Cookie in a way that conflicts with such folding.

AWS has a field called multiValueHeaders for this case:

{
  "statusCode": 200,
  "body": "testing multiple set-cookie headers",
  "headers": {
    "X-Test-Header": "baking experiment",
    "Content-Type": "text/plain"
  },
  "multiValueHeaders": {
    "Set-Cookie": ["cookie1=chocolate-chip", "cookie2=oatmeal"]
  }
}

https://stackoverflow.com/questions/39769222/how-can-i-send-multiple-set-cookie-headers-from-api-gateway-using-a-proxied-lamb

thekid commented 3 years ago

Fixed in xp-forge/lambda-ws@5f9240d