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
[fetch] Implement Headers.prototype.getSetCookie
.
#9490
[fetch] Implement Headers.prototype.getSetCookie
.
#9490
Conversation
EWS run on previous version of this PR (hash 44b6fee) |
I didn't add tests because there is a WPT PR (web-platform-tests/wpt#31442) that hasn't been merged yet. Or should I add that test to this PR for now, to run it under CI? I would appreciate comments on the iterator changes and on the I also need to document this to some degree. |
EWS run on previous version of this PR (hash fda8054) |
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.
Some suggestions below.
This patch needs tests, ideally WPT tests.
EWS run on previous version of this PR (hash 3fe363b) |
About WPT, there's a PR at web-platform-tests/wpt#31442. I just pushed a few additional tests there, including one for iteration invalidation. |
3fe363b
to
8c11cca
Compare
Headers.prototype.getSetCookie
.
EWS run on previous version of this PR (hash 8c11cca) |
8c11cca
to
5db5b93
Compare
Headers.prototype.getSetCookie
.
Sorry for the PR rename churn, this is my first time working with Webkit's Github workflow, and I didn't realize Anyway, the WPT PR has now been merged (as well as the spec PR), and I've updated this PR to include those tests. |
EWS run on previous version of this PR (hash 5db5b93) |
5db5b93
to
1754f2d
Compare
EWS run on previous version of this PR (hash 1754f2d) |
1754f2d
to
b0beebe
Compare
EWS run on previous version of this PR (hash b0beebe) |
b0beebe
to
5590d0a
Compare
EWS run on previous version of this PR (hash 5590d0a) |
5590d0a
to
1ebee5c
Compare
EWS run on previous version of this PR (hash 1ebee5c) |
|
||
if (equalIgnoringASCIICase(name, "Set-Cookie"_str)) { | ||
if (m_setCookieValues.isEmpty()) | ||
return String(); |
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 probably do not need to optimize this case.
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.
This is just about the size-0 case, right? The size-1 optimization can stay.
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.
Oh, I hadn't realized that returning String()
on the size-0 case isn't an optimization, since get()
must return null
. The size-1 case is an optimization, but not apparently one that would achieve anything, since it seems like StringBuilder
directly uses the passed string in this case.
I'm therefore keeping the size-0 case and removing the size-1 case.
Looks almost ready to me, some nits below. |
1ebee5c
to
65dd602
Compare
EWS run on previous version of this PR (hash 65dd602) |
I opened web-platform-tests/wpt#38437 |
65dd602
to
c0d625c
Compare
EWS run on previous version of this PR (hash c0d625c) |
c0d625c
to
587388e
Compare
EWS run on previous version of this PR (hash 587388e) |
@youennf PTAL |
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.
LGTM
587388e
to
c6b5177
Compare
EWS run on current version of this PR (hash c6b5177) |
https://bugs.webkit.org/show_bug.cgi?id=251194 Reviewed by Youenn Fablet. This change implements the `getSetCookie` method of the fetch spec's `Headers` interface. This change allows storing `Set-Cookie` headers as a list of values, and retrieving the separate values, rather than their combined representation, which is ambiguous. This change also makes it so iterating through `Headers` objects will yield `Set-Cookie` headers separately rather than combined, which is part of the same change in the fetch spec. Given that `Set-Cookie` is a forbidden header name in both requests and responses, this will not be useful for any uses of `Headers` related to fetch. It does allows some non-fetch use cases, however, and enables further compatibility with server-side runtimes that do allow this header. Rather than refactoring `HTTPHeaderMap` to not combine (all) headers, this implementation makes use of the fact that `Set-Cookie` is forbidden for both requests and responses, to store the `Set-Cookie` values in a vector of strings directly in `FetchHeaders` instead. This needed such header name to be special-cased in almost every operation of this class. And in order to have `Set-Cookie` headers properly appear in their right order in the pair iterator, `m_keys` has been changed to be a pair where the second element is an index into the `Set-Cookie` values vector, which is ignored for other header names. Fetch spec PR: whatwg/fetch#1346 This commit also imports the corresponding WPT tests from web-platform-tests/wpt#31442, and adds some additional tests. * Source/WebCore/Modules/fetch/FetchHeaders.cpp: (WebCore::appendToHeaderMap): (WebCore::fillHeaderMap): (WebCore::FetchHeaders::create): (WebCore::FetchHeaders::fill): (WebCore::FetchHeaders::append): (WebCore::FetchHeaders::remove): (WebCore::FetchHeaders::get const): (WebCore::FetchHeaders::getSetCookie const): (WebCore::FetchHeaders::has const): (WebCore::FetchHeaders::set): (WebCore::FetchHeaders::Iterator::next): * Source/WebCore/Modules/fetch/FetchHeaders.h: (WebCore::FetchHeaders::create): (WebCore::FetchHeaders::fastGet const): (WebCore::FetchHeaders::fastHas const): (WebCore::FetchHeaders::fastSet): (WebCore::FetchHeaders::FetchHeaders): * Source/WebCore/Modules/fetch/FetchHeaders.idl: * Source/WebCore/platform/network/ResourceResponseBase.cpp: (WebCore::ResourceResponseBase::httpHeaderField const): Canonical link: https://commits.webkit.org/260533@main
c6b5177
to
77fd8de
Compare
Committed 260533@main (77fd8de): https://commits.webkit.org/260533@main Reviewed commits have been landed. Closing PR #9490 and removing active labels. |
77fd8de
c6b5177
π§ͺ api-gtkπ§ͺ mac-AS-debug-wk2