Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(795)

Unified Diff: third_party/WebKit/Source/modules/fetch/FetchHeaderList.cpp

Issue 2559273005: [Fetch API] Implement combining of Headers with same keys. (Closed)
Patch Set: fix Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/WebKit/LayoutTests/http/tests/fetch/script-tests/headers.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/modules/fetch/FetchHeaderList.cpp
diff --git a/third_party/WebKit/Source/modules/fetch/FetchHeaderList.cpp b/third_party/WebKit/Source/modules/fetch/FetchHeaderList.cpp
index abbd34f37ca60b78591f37db5f8b40c32a4f4b05..ca24581c50d6d8947f534060708b79cfea3f77c1 100644
--- a/third_party/WebKit/Source/modules/fetch/FetchHeaderList.cpp
+++ b/third_party/WebKit/Source/modules/fetch/FetchHeaderList.cpp
@@ -130,14 +130,22 @@ bool FetchHeaderList::containsNonSimpleHeader() const {
void FetchHeaderList::sortAndCombine() {
// https://fetch.spec.whatwg.org/#concept-header-list-sort-and-combine
// "To sort and combine a header list..."
-
- // TODO(jsbell): Implement the combining part - this currently just sorts.
+ if (m_headerList.isEmpty())
+ return;
std::sort(
m_headerList.begin(), m_headerList.end(),
[](const std::unique_ptr<Header>& a, const std::unique_ptr<Header>& b) {
return WTF::codePointCompareLessThan(a->first, b->first);
});
+
+ for (size_t index = m_headerList.size() - 1; index > 0; --index) {
+ if (m_headerList[index - 1]->first == m_headerList[index]->first) {
+ m_headerList[index - 1]->second.append(",");
+ m_headerList[index - 1]->second.append(m_headerList[index]->second);
+ m_headerList.remove(index, 1);
+ }
+ }
}
bool FetchHeaderList::isValidHeaderName(const String& name) {
« no previous file with comments | « third_party/WebKit/LayoutTests/http/tests/fetch/script-tests/headers.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698