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 (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.
| |
92 result = m_headerList[i]->second; | 92 if (header->first == lowercasedName) { |
93 return true; | 93 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
| |
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 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.
| |
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 |