-
Notifications
You must be signed in to change notification settings - Fork 473
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
Headers ordering #162
Comments
The gb_tree data structure is necessary for performance reasons. What's your use case? When multiple headers with the same name are present, they are combined in the order that they were received.
|
I am using mochiweb like a proxy, so I need to pass a server response to the client and the server response headers are like:
but when passing through mochiweb, it returns:
Which sets incorrect cookie on the client side. |
Order for Set-Cookie is preserved. Are you doing some sort of transformation? How exactly are you generating the headers for the response? 1> mochiweb_headers:to_list(mochiweb_headers:make([{"Set-Cookie", "selectedCountry=GB"}, {"Set-Cookie", "selectedCountry=US"}])).
[{"Set-Cookie","selectedCountry=GB"},
{"Set-Cookie","selectedCountry=US"}] This ordering property is tested (in a few places, here's one): set_cookie_test() ->
H = make([{"set-cookie", foo}, {"set-cookie", bar}, {"set-cookie", baz}]),
?assertEqual(
[{"set-cookie", "foo"}, {"set-cookie", "bar"}, {"set-cookie", "baz"}],
to_list(H)),
ok. |
Ok, I found the issue, it's with formatting the headers in the response, not with mochiweb_headers itself. |
thanks for this 👍 |
In some cases headers order matter, like here
Could this be changed somehow? and why is it important to handle headers on a
gb_tree
structure?The text was updated successfully, but these errors were encountered: