-
Notifications
You must be signed in to change notification settings - Fork 3k
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
fix iterating headers with set-cookie
#4048
Conversation
There is a bug in building that still has to get investigated. |
❌ @dylan-conway 4 files with test failures on bun-darwin-aarch64:
|
❌ @dylan-conway 2 files with test failures on linux-x64-baseline:
|
❌ @dylan-conway 3 files with test failures on linux-x64:
|
❌ @dylan-conway 7 files with test failures on bun-darwin-x64-baseline:
|
for (auto& header : m_headers->m_headers) | ||
m_keys.uncheckedAppend(header.asciiLowerCaseName()); | ||
std::sort(m_keys.begin(), m_keys.end(), WTF::codePointCompareLessThan); | ||
if (hasSetCookie) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need to pay this performance overhead here? Wouldn't it be fine if we put the Set-Cookie header either first or last?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we do, this is part of the fetch spec https://fetch.spec.whatwg.org/#convert-header-names-to-a-sorted-lowercase-set
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It was also expected in the spec for keys to be unique which isn’t true for set-cookies
I think we should just always put it at the end and call it a day. Each call to next() shouldn’t slow it down
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated to append after the sort
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These changes should be moved to HTTPHeaderMap to avoid duplicate work
Thank you |
* fix iterating headers with `set-cookie` * a test * move work to `HTTPHeaderMap::set` * append set-cookie after sort * remove compare function
What does this PR do?
before:
after:
// output: [ [ "content-type", "application/json" ], [ "set-cookie", "cookies" ] ]
How did you verify your code works?
updated and added test for headers with
set-cookie