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

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: it will be nicer. 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..d3a0ee7235986bd4f1a64654fe4971be5ac023ff 100644
--- a/third_party/WebKit/Source/modules/fetch/FetchHeaderList.cpp
+++ b/third_party/WebKit/Source/modules/fetch/FetchHeaderList.cpp
@@ -30,7 +30,8 @@ void FetchHeaderList::append(const String& name, const String& value) {
// "To append a name/value (|name|/|value|) pair to a header list (|list|),
// append a new header whose name is |name|, byte lowercased, and value is
// |value|, to |list|."
- m_headerList.append(WTF::wrapUnique(new Header(name.lower(), value)));
+ if (!value.isEmpty())
jsbell 2016/12/16 22:29:37 This seems incorrect - the caller (Headers::append
+ m_headerList.append(WTF::wrapUnique(new Header(name.lower(), value)));
}
void FetchHeaderList::set(const String& name, const String& value) {
@@ -87,13 +88,18 @@ 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;
+ for (const auto& header : m_headerList) {
+ DCHECK(!header->second.isEmpty());
+ if (header->first == lowercasedName) {
+ if (result.isEmpty()) {
+ result = header->second;
+ } else {
+ result.append(",");
+ result.append(header->second);
+ }
}
}
- return false;
+ return !result.isEmpty();
}
void FetchHeaderList::getAll(const String& name, Vector<String>& result) const {

Powered by Google App Engine
This is Rietveld 408576698