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 "core/fetch/FetchUtils.h" | 5 #include "core/fetch/FetchUtils.h" |
6 | 6 |
7 #include "platform/HTTPNames.h" | 7 #include "platform/HTTPNames.h" |
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 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
98 // Treat inspector header as a simple header, since it is added by blink whe
n | 98 // Treat inspector header as a simple header, since it is added by blink whe
n |
99 // inspector is open. | 99 // inspector is open. |
100 | 100 |
101 if (equalIgnoringCase(name, "accept") | 101 if (equalIgnoringCase(name, "accept") |
102 || equalIgnoringCase(name, "accept-language") | 102 || equalIgnoringCase(name, "accept-language") |
103 || equalIgnoringCase(name, "content-language") | 103 || equalIgnoringCase(name, "content-language") |
104 || equalIgnoringCase(name, HTTPNames::X_DevTools_Emulate_Network_Conditi
ons_Client_Id) | 104 || equalIgnoringCase(name, HTTPNames::X_DevTools_Emulate_Network_Conditi
ons_Client_Id) |
105 || equalIgnoringCase(name, "save-data")) | 105 || equalIgnoringCase(name, "save-data")) |
106 return true; | 106 return true; |
107 | 107 |
108 if (equalIgnoringCase(name, "content-type")) { | 108 if (equalIgnoringCase(name, "content-type")) |
109 AtomicString mimeType = extractMIMETypeFromMediaType(value); | 109 return isSimpleContentType(value); |
110 return equalIgnoringCase(mimeType, "application/x-www-form-urlencoded") | |
111 || equalIgnoringCase(mimeType, "multipart/form-data") | |
112 || equalIgnoringCase(mimeType, "text/plain"); | |
113 } | |
114 | 110 |
115 return false; | 111 return false; |
116 } | 112 } |
117 | 113 |
| 114 bool FetchUtils::isSimpleContentType(const AtomicString& mediaType) |
| 115 { |
| 116 AtomicString mimeType = extractMIMETypeFromMediaType(mediaType); |
| 117 return equalIgnoringCase(mimeType, "application/x-www-form-urlencoded") |
| 118 || equalIgnoringCase(mimeType, "multipart/form-data") |
| 119 || equalIgnoringCase(mimeType, "text/plain"); |
| 120 } |
| 121 |
118 bool FetchUtils::isSimpleRequest(const String& method, const HTTPHeaderMap& head
erMap) | 122 bool FetchUtils::isSimpleRequest(const String& method, const HTTPHeaderMap& head
erMap) |
119 { | 123 { |
120 if (!isSimpleMethod(method)) | 124 if (!isSimpleMethod(method)) |
121 return false; | 125 return false; |
122 | 126 |
123 for (const auto& header : headerMap) { | 127 for (const auto& header : headerMap) { |
124 // Preflight is required for MIME types that can not be sent via form | 128 // Preflight is required for MIME types that can not be sent via form |
125 // submission. | 129 // submission. |
126 if (!isSimpleHeader(header.key, header.value)) | 130 if (!isSimpleHeader(header.key, header.value)) |
127 return false; | 131 return false; |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
205 String FetchUtils::normalizeHeaderValue(const String& value) | 209 String FetchUtils::normalizeHeaderValue(const String& value) |
206 { | 210 { |
207 // https://fetch.spec.whatwg.org/#concept-header-value-normalize | 211 // https://fetch.spec.whatwg.org/#concept-header-value-normalize |
208 // Strip leading and trailing whitespace from header value. | 212 // Strip leading and trailing whitespace from header value. |
209 // HTTP whitespace bytes are 0x09, 0x0A, 0x0D, and 0x20. | 213 // HTTP whitespace bytes are 0x09, 0x0A, 0x0D, and 0x20. |
210 | 214 |
211 return value.stripWhiteSpace(isHTTPWhitespace); | 215 return value.stripWhiteSpace(isHTTPWhitespace); |
212 } | 216 } |
213 | 217 |
214 } // namespace blink | 218 } // namespace blink |
OLD | NEW |