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

Side by Side 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 unified diff | 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "modules/fetch/FetchHeaderList.h" 5 #include "modules/fetch/FetchHeaderList.h"
6 6
7 #include "core/fetch/FetchUtils.h" 7 #include "core/fetch/FetchUtils.h"
8 #include "platform/network/HTTPParsers.h" 8 #include "platform/network/HTTPParsers.h"
9 #include "wtf/PtrUtil.h" 9 #include "wtf/PtrUtil.h"
10 #include <algorithm> 10 #include <algorithm>
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 if (!FetchUtils::isSimpleHeader(AtomicString(m_headerList[i]->first), 123 if (!FetchUtils::isSimpleHeader(AtomicString(m_headerList[i]->first),
124 AtomicString(m_headerList[i]->second))) 124 AtomicString(m_headerList[i]->second)))
125 return true; 125 return true;
126 } 126 }
127 return false; 127 return false;
128 } 128 }
129 129
130 void FetchHeaderList::sortAndCombine() { 130 void FetchHeaderList::sortAndCombine() {
131 // https://fetch.spec.whatwg.org/#concept-header-list-sort-and-combine 131 // https://fetch.spec.whatwg.org/#concept-header-list-sort-and-combine
132 // "To sort and combine a header list..." 132 // "To sort and combine a header list..."
133 133 if (m_headerList.isEmpty())
134 // TODO(jsbell): Implement the combining part - this currently just sorts. 134 return;
135 135
136 std::sort( 136 std::sort(
137 m_headerList.begin(), m_headerList.end(), 137 m_headerList.begin(), m_headerList.end(),
138 [](const std::unique_ptr<Header>& a, const std::unique_ptr<Header>& b) { 138 [](const std::unique_ptr<Header>& a, const std::unique_ptr<Header>& b) {
139 return WTF::codePointCompareLessThan(a->first, b->first); 139 return WTF::codePointCompareLessThan(a->first, b->first);
140 }); 140 });
141
142 for (size_t index = m_headerList.size() - 1; index > 0; --index) {
143 if (m_headerList[index - 1]->first == m_headerList[index]->first) {
144 m_headerList[index - 1]->second.append(",");
145 m_headerList[index - 1]->second.append(m_headerList[index]->second);
146 m_headerList.remove(index, 1);
147 }
148 }
141 } 149 }
142 150
143 bool FetchHeaderList::isValidHeaderName(const String& name) { 151 bool FetchHeaderList::isValidHeaderName(const String& name) {
144 // "A name is a case-insensitive byte sequence that matches the field-name 152 // "A name is a case-insensitive byte sequence that matches the field-name
145 // token production." 153 // token production."
146 return isValidHTTPToken(name); 154 return isValidHTTPToken(name);
147 } 155 }
148 156
149 bool FetchHeaderList::isValidHeaderValue(const String& value) { 157 bool FetchHeaderList::isValidHeaderValue(const String& value) {
150 // "A value is a byte sequence that matches the field-value token production 158 // "A value is a byte sequence that matches the field-value token production
151 // and contains no 0x0A or 0x0D bytes." 159 // and contains no 0x0A or 0x0D bytes."
152 return isValidHTTPHeaderValue(value); 160 return isValidHTTPHeaderValue(value);
153 } 161 }
154 162
155 } // namespace blink 163 } // namespace blink
OLDNEW
« 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