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

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

Issue 2542073005: Sort headers for iteration (Closed)
Patch Set: Rebased 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
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 b757b11af3c19d30d7eea8e9f03bee3800cc063c..f8061121b6c12cf09ce33e6d723e1b0a1d59749d 100644
--- a/third_party/WebKit/Source/modules/fetch/FetchHeaderList.cpp
+++ b/third_party/WebKit/Source/modules/fetch/FetchHeaderList.cpp
@@ -7,6 +7,7 @@
#include "core/fetch/FetchUtils.h"
#include "platform/network/HTTPParsers.h"
#include "wtf/PtrUtil.h"
+#include <algorithm>
namespace blink {
@@ -14,7 +15,7 @@ FetchHeaderList* FetchHeaderList::create() {
return new FetchHeaderList();
}
-FetchHeaderList* FetchHeaderList::clone() {
+FetchHeaderList* FetchHeaderList::clone() const {
FetchHeaderList* list = create();
for (size_t i = 0; i < m_headerList.size(); ++i)
list->append(m_headerList[i]->first, m_headerList[i]->second);
@@ -126,6 +127,19 @@ bool FetchHeaderList::containsNonSimpleHeader() const {
return false;
}
+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);
+ });
+}
+
bool FetchHeaderList::isValidHeaderName(const String& name) {
// "A name is a case-insensitive byte sequence that matches the field-name
// token production."
« no previous file with comments | « third_party/WebKit/Source/modules/fetch/FetchHeaderList.h ('k') | third_party/WebKit/Source/modules/fetch/Headers.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698