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

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

Issue 2587463002: [Fetch API] Appending headers of the same name should have their values (Closed)
Patch Set: 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 ca24581c50d6d8947f534060708b79cfea3f77c1..2130a8fada120dab028126015202454fe3f6f194 100644
--- a/third_party/WebKit/Source/modules/fetch/FetchHeaderList.cpp
+++ b/third_party/WebKit/Source/modules/fetch/FetchHeaderList.cpp
@@ -87,13 +87,19 @@ void FetchHeaderList::remove(const String& name) {
bool FetchHeaderList::get(const String& name, String& result) const {
const String lowercasedName = name.lower();
- for (size_t i = 0; i < m_headerList.size(); ++i) {
- if (m_headerList[i]->first == lowercasedName) {
- result = m_headerList[i]->second;
- return true;
+ bool flag = false;
+ for (auto&& header : m_headerList) {
jsbell 2016/12/16 17:58:26 Do we have a preference for auto&& vs. const auto&
dhna 2016/12/16 18:33:35 I like your suggestion.
+ if (header->first == lowercasedName) {
+ if (result.isEmpty()) {
jsbell 2016/12/16 17:58:26 My reading of the spec is that values may not be e
dhna 2016/12/16 18:33:35 jsbell@ If we meet a first key value matched. In t
jsbell 2016/12/16 18:55:59 To clarify: I agree the code is correct. I do not
jsbell 2016/12/16 18:57:32 And to clarify one more time: I mean that your pro
+ result = header->second;
+ flag = true;
+ } else {
+ result.append(",");
+ result.append(header->second);
+ }
}
}
- return false;
+ return flag;
jsbell 2016/12/16 17:58:26 Do we need flag, or can it just be !result.isEmpty
dhna 2016/12/16 18:33:35 I like this suggestion also.
}
void FetchHeaderList::getAll(const String& name, Vector<String>& result) const {

Powered by Google App Engine
This is Rietveld 408576698