Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(110)

Side by Side Diff: third_party/WebKit/Source/core/fetch/FetchUtils.cpp

Issue 1698973002: Exempt Save-Data header from CORS preflight request check (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added layout test Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/network/HTTPHeaderMap.h" 7 #include "platform/network/HTTPHeaderMap.h"
8 #include "platform/network/HTTPParsers.h" 8 #include "platform/network/HTTPParsers.h"
9 #include "wtf/HashSet.h" 9 #include "wtf/HashSet.h"
10 #include "wtf/Threading.h" 10 #include "wtf/Threading.h"
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 } 83 }
84 84
85 bool FetchUtils::isSimpleHeader(const AtomicString& name, const AtomicString& va lue) 85 bool FetchUtils::isSimpleHeader(const AtomicString& name, const AtomicString& va lue)
86 { 86 {
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
94 // Data Saver feature is enabled.
93 95
94 if (equalIgnoringCase(name, "accept") 96 if (equalIgnoringCase(name, "accept")
95 || equalIgnoringCase(name, "accept-language") 97 || equalIgnoringCase(name, "accept-language")
96 || equalIgnoringCase(name, "content-language")) 98 || equalIgnoringCase(name, "content-language")
99 || equalIgnoringCase(name, "save-data"))
97 return true; 100 return true;
98 101
99 if (equalIgnoringCase(name, "content-type")) { 102 if (equalIgnoringCase(name, "content-type")) {
100 AtomicString mimeType = extractMIMETypeFromMediaType(value); 103 AtomicString mimeType = extractMIMETypeFromMediaType(value);
101 return equalIgnoringCase(mimeType, "application/x-www-form-urlencoded") 104 return equalIgnoringCase(mimeType, "application/x-www-form-urlencoded")
102 || equalIgnoringCase(mimeType, "multipart/form-data") 105 || equalIgnoringCase(mimeType, "multipart/form-data")
103 || equalIgnoringCase(mimeType, "text/plain"); 106 || equalIgnoringCase(mimeType, "text/plain");
104 } 107 }
105 108
106 return false; 109 return false;
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
196 String FetchUtils::normalizeHeaderValue(const String& value) 199 String FetchUtils::normalizeHeaderValue(const String& value)
197 { 200 {
198 // https://fetch.spec.whatwg.org/#concept-header-value-normalize 201 // https://fetch.spec.whatwg.org/#concept-header-value-normalize
199 // Strip leading and trailing whitespace from header value. 202 // Strip leading and trailing whitespace from header value.
200 // HTTP whitespace bytes are 0x09, 0x0A, 0x0D, and 0x20. 203 // HTTP whitespace bytes are 0x09, 0x0A, 0x0D, and 0x20.
201 204
202 return value.stripWhiteSpace(isHTTPWhitespace); 205 return value.stripWhiteSpace(isHTTPWhitespace);
203 } 206 }
204 207
205 } // namespace blink 208 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/LayoutTests/http/tests/xmlhttprequest/access-control-preflight-data-saver-expected.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698