Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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 flag = 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 (result.isEmpty()) { |
|
jsbell
2016/12/16 23:45:46
Shouldn't this test be (!flag) ?
| |
| 94 result = header->second; | |
| 95 flag = true; | |
| 96 } else { | |
| 97 result.append(","); | |
| 98 result.append(header->second); | |
| 99 } | |
| 94 } | 100 } |
| 95 } | 101 } |
| 96 return false; | 102 return !result.isEmpty(); |
|
jsbell
2016/12/16 23:45:46
Won't this return false if there is only one match
dhna
2016/12/16 23:57:44
Oh it's my mistake sorry.
| |
| 97 } | 103 } |
| 98 | 104 |
| 99 void FetchHeaderList::getAll(const String& name, Vector<String>& result) const { | 105 void FetchHeaderList::getAll(const String& name, Vector<String>& result) const { |
| 100 const String lowercasedName = name.lower(); | 106 const String lowercasedName = name.lower(); |
| 101 result.clear(); | 107 result.clear(); |
| 102 for (size_t i = 0; i < m_headerList.size(); ++i) { | 108 for (size_t i = 0; i < m_headerList.size(); ++i) { |
| 103 if (m_headerList[i]->first == lowercasedName) | 109 if (m_headerList[i]->first == lowercasedName) |
| 104 result.append(m_headerList[i]->second); | 110 result.append(m_headerList[i]->second); |
| 105 } | 111 } |
| 106 } | 112 } |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 154 return isValidHTTPToken(name); | 160 return isValidHTTPToken(name); |
| 155 } | 161 } |
| 156 | 162 |
| 157 bool FetchHeaderList::isValidHeaderValue(const String& value) { | 163 bool FetchHeaderList::isValidHeaderValue(const String& value) { |
| 158 // "A value is a byte sequence that matches the field-value token production | 164 // "A value is a byte sequence that matches the field-value token production |
| 159 // and contains no 0x0A or 0x0D bytes." | 165 // and contains no 0x0A or 0x0D bytes." |
| 160 return isValidHTTPHeaderValue(value); | 166 return isValidHTTPHeaderValue(value); |
| 161 } | 167 } |
| 162 | 168 |
| 163 } // namespace blink | 169 } // namespace blink |
| OLD | NEW |