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

Side by Side 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: flag to found 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
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 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 for (size_t i = 0; i < m_headerList.size();) { 80 for (size_t i = 0; i < m_headerList.size();) {
81 if (m_headerList[i]->first == lowercasedName) 81 if (m_headerList[i]->first == lowercasedName)
82 m_headerList.remove(i); 82 m_headerList.remove(i);
83 else 83 else
84 ++i; 84 ++i;
85 } 85 }
86 } 86 }
87 87
88 bool FetchHeaderList::get(const String& name, String& result) const { 88 bool FetchHeaderList::get(const String& name, String& result) const {
89 const String lowercasedName = name.lower(); 89 const String lowercasedName = name.lower();
90 for (size_t i = 0; i < m_headerList.size(); ++i) { 90 bool found = false;
91 if (m_headerList[i]->first == lowercasedName) { 91 for (const auto& header : m_headerList) {
92 result = m_headerList[i]->second; 92 if (header->first == lowercasedName) {
93 return true; 93 if (!found) {
94 result = "";
95 result.append(header->second);
96 found = true;
97 } else {
98 result.append(",");
99 result.append(header->second);
100 }
94 } 101 }
95 } 102 }
96 return false; 103 return found;
97 } 104 }
98 105
99 void FetchHeaderList::getAll(const String& name, Vector<String>& result) const { 106 void FetchHeaderList::getAll(const String& name, Vector<String>& result) const {
100 const String lowercasedName = name.lower(); 107 const String lowercasedName = name.lower();
101 result.clear(); 108 result.clear();
102 for (size_t i = 0; i < m_headerList.size(); ++i) { 109 for (size_t i = 0; i < m_headerList.size(); ++i) {
103 if (m_headerList[i]->first == lowercasedName) 110 if (m_headerList[i]->first == lowercasedName)
104 result.append(m_headerList[i]->second); 111 result.append(m_headerList[i]->second);
105 } 112 }
106 } 113 }
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 return isValidHTTPToken(name); 161 return isValidHTTPToken(name);
155 } 162 }
156 163
157 bool FetchHeaderList::isValidHeaderValue(const String& value) { 164 bool FetchHeaderList::isValidHeaderValue(const String& value) {
158 // "A value is a byte sequence that matches the field-value token production 165 // "A value is a byte sequence that matches the field-value token production
159 // and contains no 0x0A or 0x0D bytes." 166 // and contains no 0x0A or 0x0D bytes."
160 return isValidHTTPHeaderValue(value); 167 return isValidHTTPHeaderValue(value);
161 } 168 }
162 169
163 } // namespace blink 170 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698