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 "platform/loader/fetch/FetchUtils.h" | 5 #include "platform/loader/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 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 bool FetchUtils::isSimpleHeader(const AtomicString& name, | 85 bool FetchUtils::isSimpleHeader(const AtomicString& name, |
86 const AtomicString& value) { | 86 const AtomicString& value) { |
87 // http://fetch.spec.whatwg.org/#simple-header | 87 // http://fetch.spec.whatwg.org/#simple-header |
88 // "A simple header is a header whose name is either one of `Accept`, | 88 // "A simple header is a header whose name is either one of `Accept`, |
89 // `Accept-Language`, and `Content-Language`, or whose name is | 89 // `Accept-Language`, and `Content-Language`, or whose name is |
90 // `Content-Type` and value, once parsed, is one of | 90 // `Content-Type` and value, once parsed, is one of |
91 // `application/x-www-form-urlencoded`, `multipart/form-data`, and | 91 // `application/x-www-form-urlencoded`, `multipart/form-data`, and |
92 // `text/plain`." | 92 // `text/plain`." |
93 // Treat 'Save-Data' as a simple header, since it is added by Chrome when | 93 // Treat 'Save-Data' as a simple header, since it is added by Chrome when |
94 // Data Saver feature is enabled. | 94 // Data Saver feature is enabled. |
95 // Treat inspector header as a simple header, since it is added by blink when | 95 // Treat inspector headers as a simple headers, since they are added by blink |
96 // inspector is open. | 96 // when the inspector is open. |
97 | 97 |
98 if (equalIgnoringCase(name, "accept") || | 98 if (equalIgnoringCase(name, "accept") || |
99 equalIgnoringCase(name, "accept-language") || | 99 equalIgnoringCase(name, "accept-language") || |
100 equalIgnoringCase(name, "content-language") || | 100 equalIgnoringCase(name, "content-language") || |
101 equalIgnoringCase( | 101 equalIgnoringCase( |
102 name, HTTPNames::X_DevTools_Emulate_Network_Conditions_Client_Id) || | 102 name, HTTPNames::X_DevTools_Emulate_Network_Conditions_Client_Id) || |
| 103 equalIgnoringCase(name, HTTPNames::X_DevTools_Request_Id) || |
103 equalIgnoringCase(name, "save-data")) | 104 equalIgnoringCase(name, "save-data")) |
104 return true; | 105 return true; |
105 | 106 |
106 if (equalIgnoringCase(name, "content-type")) | 107 if (equalIgnoringCase(name, "content-type")) |
107 return isSimpleContentType(value); | 108 return isSimpleContentType(value); |
108 | 109 |
109 return false; | 110 return false; |
110 } | 111 } |
111 | 112 |
112 bool FetchUtils::isSimpleContentType(const AtomicString& mediaType) { | 113 bool FetchUtils::isSimpleContentType(const AtomicString& mediaType) { |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
198 | 199 |
199 String FetchUtils::normalizeHeaderValue(const String& value) { | 200 String FetchUtils::normalizeHeaderValue(const String& value) { |
200 // https://fetch.spec.whatwg.org/#concept-header-value-normalize | 201 // https://fetch.spec.whatwg.org/#concept-header-value-normalize |
201 // Strip leading and trailing whitespace from header value. | 202 // Strip leading and trailing whitespace from header value. |
202 // HTTP whitespace bytes are 0x09, 0x0A, 0x0D, and 0x20. | 203 // HTTP whitespace bytes are 0x09, 0x0A, 0x0D, and 0x20. |
203 | 204 |
204 return value.stripWhiteSpace(isHTTPWhitespace); | 205 return value.stripWhiteSpace(isHTTPWhitespace); |
205 } | 206 } |
206 | 207 |
207 } // namespace blink | 208 } // namespace blink |
OLD | NEW |