CrowdHailer / raxx

Interface for HTTP webservers, frameworks and clients
https://hexdocs.pm/raxx
Apache License 2.0
400 stars 29 forks source link

allow to set multiple cookies #163

Closed SchrodingerZhu closed 5 years ago

SchrodingerZhu commented 5 years ago

I have to use Map.update! to set multiple cookies now. I suggest we should allow user to insert multiple set-cookie items in header.

CrowdHailer commented 5 years ago

This makes sense. What API would you suggest? The cookie headers are special cases in HTTP requests because there are different rules for combining multiple cookie headers, so I've never been sure if this should live in Raxx core or the cookie project somehow

SchrodingerZhu commented 5 years ago

Raxx.set_header will keep me from inserting multiple cookies. But as I have mentioned before, simply use Map.update! to append new cookie structure like {"set-cookie", "foo=bar"} in the response.header seems working smoothly. Raxx seems to have the ability to handle multiple {"set-cookie", _} items correctly. Maybe add a special conflict check for set-cookie header or just a new method to handle cookies?

CrowdHailer commented 5 years ago

A new method to handle cookies makes sense, however everything relating to cookies I have extracted to the cookie project. https://hex.pm/packages/cookie

CrowdHailer commented 5 years ago

I think I will close this issue, in favour of improving the :cookie project.

Nicd commented 4 years ago

This issue should not be closed, because the cookie package does not handle set-cookie header at all. Currently it's not possible to have multiple set-cookie headers in Raxx and the cookie library cannot change that because it's a Raxx limitation.