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..007807096a82e3026ce8906f910e0509422b8866 100644 |
--- a/third_party/WebKit/Source/modules/fetch/FetchHeaderList.cpp |
+++ b/third_party/WebKit/Source/modules/fetch/FetchHeaderList.cpp |
@@ -130,14 +130,23 @@ 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. |
- |
- 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); |
- }); |
+ if (m_headerList.size() > 1) { |
jsbell
2016/12/12 21:00:24
This would be simpler as:
if (m_headerList.isEmpt
|
+ 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;) { |
+ 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); |
+ } else { |
+ --index; |
+ } |
+ } |
+ } |
} |
bool FetchHeaderList::isValidHeaderName(const String& name) { |