purescript-payload icon indicating copy to clipboard operation
purescript-payload copied to clipboard

Payload.Headers should accept repeated headers

Open kaol opened this issue 3 years ago • 1 comments

HTTP spec allows for repeated headers in requests and responses.

https://www.w3.org/Protocols/rfc2616/rfc2616-sec4.html#sec4.2

~As far as generating responses go, there's the alternative of combining them as a comma separated list. Payload is doing neither and doing something like setting Set-Cookie header twice only uses one of those values.~ On second look, https://www.rfc-editor.org/rfc/rfc6265#page-6 says that Set-Cookie headers shouldn't do that.

I didn't check how Payload does request parsing but I'd expect it to discard headers on that end as well.

kaol avatar Nov 18 '21 11:11 kaol

I had a need for getting repeated Set-Cookie headers to work. The key was to call Node.HTTP.setHeaders alongside with Node.HTTP.setHeader. For a proper PR I'd likely involve Payload.Server.Cookies as well, this one takes a shortcut and uses just strings.

See https://github.com/KSF-Media/purescript-payload/tree/repeated-set-cookie

kaol avatar Sep 27 '22 13:09 kaol