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 "config.h" | 5 #include "config.h" |
6 #include "core/fetch/FetchUtils.h" | 6 #include "core/fetch/FetchUtils.h" |
7 | 7 |
8 #include "platform/network/HTTPHeaderMap.h" | 8 #include "platform/network/HTTPHeaderMap.h" |
9 #include "platform/network/HTTPParsers.h" | 9 #include "platform/network/HTTPParsers.h" |
10 #include "wtf/HashSet.h" | 10 #include "wtf/HashSet.h" |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
100 } | 100 } |
101 | 101 |
102 return false; | 102 return false; |
103 } | 103 } |
104 | 104 |
105 bool FetchUtils::isSimpleRequest(const String& method, const HTTPHeaderMap& head
erMap) | 105 bool FetchUtils::isSimpleRequest(const String& method, const HTTPHeaderMap& head
erMap) |
106 { | 106 { |
107 if (!isSimpleMethod(method)) | 107 if (!isSimpleMethod(method)) |
108 return false; | 108 return false; |
109 | 109 |
110 HTTPHeaderMap::const_iterator end = headerMap.end(); | 110 for (const auto& header : headerMap) { |
111 for (HTTPHeaderMap::const_iterator it = headerMap.begin(); it != end; ++it)
{ | |
112 // Preflight is required for MIME types that can not be sent via form | 111 // Preflight is required for MIME types that can not be sent via form |
113 // submission. | 112 // submission. |
114 if (!isSimpleHeader(it->key, it->value)) | 113 if (!isSimpleHeader(header.key, header.value)) |
115 return false; | 114 return false; |
116 } | 115 } |
117 | 116 |
118 return true; | 117 return true; |
119 } | 118 } |
120 | 119 |
121 bool FetchUtils::isForbiddenMethod(const String& method) | 120 bool FetchUtils::isForbiddenMethod(const String& method) |
122 { | 121 { |
123 // http://fetch.spec.whatwg.org/#forbidden-method | 122 // http://fetch.spec.whatwg.org/#forbidden-method |
124 // "A forbidden method is a method that is a byte case-insensitive match" | 123 // "A forbidden method is a method that is a byte case-insensitive match" |
(...skipping 25 matching lines...) Expand all Loading... |
150 // `Set-Cookie`, `Set-Cookie2`" | 149 // `Set-Cookie`, `Set-Cookie2`" |
151 | 150 |
152 return equalIgnoringCase(name, "set-cookie") || equalIgnoringCase(name, "set
-cookie2"); | 151 return equalIgnoringCase(name, "set-cookie") || equalIgnoringCase(name, "set
-cookie2"); |
153 } | 152 } |
154 | 153 |
155 bool FetchUtils::isSimpleOrForbiddenRequest(const String& method, const HTTPHead
erMap& headerMap) | 154 bool FetchUtils::isSimpleOrForbiddenRequest(const String& method, const HTTPHead
erMap& headerMap) |
156 { | 155 { |
157 if (!isSimpleMethod(method)) | 156 if (!isSimpleMethod(method)) |
158 return false; | 157 return false; |
159 | 158 |
160 HTTPHeaderMap::const_iterator end = headerMap.end(); | 159 for (const auto& header : headerMap) { |
161 for (HTTPHeaderMap::const_iterator it = headerMap.begin(); it != end; ++it)
{ | 160 if (!isSimpleHeader(header.key, header.value) && !isForbiddenHeaderName(
header.key)) |
162 if (!isSimpleHeader(it->key, it->value) && !isForbiddenHeaderName(it->ke
y)) | |
163 return false; | 161 return false; |
164 } | 162 } |
165 | 163 |
166 return true; | 164 return true; |
167 } | 165 } |
168 | 166 |
169 } // namespace blink | 167 } // namespace blink |
OLD | NEW |