Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot set same header twice #172

Open
JornWildt opened this issue Jan 25, 2019 · 2 comments
Open

Cannot set same header twice #172

JornWildt opened this issue Jan 25, 2019 · 2 comments

Comments

@JornWildt
Copy link

In case you need to set two cookies in the same response, the server fails:

System.ArgumentException: An item with the same key has already been added.
   at System.ThrowHelper.ThrowArgumentException(ExceptionResource resource)
   at System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add)
   at OpenRasta.Web.HttpHeaderDictionary.Add(String key, String value)

The header collection should not be a simple <string,string> dictionary.

@holytshirt holytshirt assigned holytshirt and unassigned holytshirt Feb 20, 2019
@serialseb
Copy link
Member

Hi Jorn,

The implementation choices depended mostly on normalisation of headers coming in and out, and unfortunately Set-Cookie one the only of the cases where this has been an issue, as hosts don't necessarily implement the split correctly to give browsers the non-http compliant they expect for cookies.

The master branch should already have the fix for this .Add exception.

I'll keep this open as we've reworked this, and we should add tests specifically for the cookie handling at the hosting layer.

@serialseb
Copy link
Member

Note that the owin hosting now leaves existing headers alone (so you can interact better with existing middleware)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants