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

Side by Side Diff: Source/modules/serviceworkers/FetchHeaderList.cpp

Issue 379113002: Move fetch-related predicates to core/fetch. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: rebase Created 6 years, 5 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 "config.h" 5 #include "config.h"
6 #include "FetchHeaderList.h" 6 #include "FetchHeaderList.h"
7 7
8 #include "core/fetch/CrossOriginAccessControl.h" 8 #include "core/fetch/CrossOriginAccessControl.h"
9 #include "core/xml/XMLHttpRequest.h"
10 #include "platform/network/HTTPParsers.h" 9 #include "platform/network/HTTPParsers.h"
11 #include "wtf/PassOwnPtr.h" 10 #include "wtf/PassOwnPtr.h"
12 11
13 namespace WebCore { 12 namespace WebCore {
14 13
15 PassRefPtrWillBeRawPtr<FetchHeaderList> FetchHeaderList::create() 14 PassRefPtrWillBeRawPtr<FetchHeaderList> FetchHeaderList::create()
16 { 15 {
17 return adoptRefWillBeNoop(new FetchHeaderList()); 16 return adoptRefWillBeNoop(new FetchHeaderList());
18 } 17 }
19 18
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 return isValidHTTPToken(name); 127 return isValidHTTPToken(name);
129 } 128 }
130 129
131 bool FetchHeaderList::isValidHeaderValue(const String& value) 130 bool FetchHeaderList::isValidHeaderValue(const String& value)
132 { 131 {
133 // "A value is a byte sequence that matches the field-value token production 132 // "A value is a byte sequence that matches the field-value token production
134 // and contains no 0x0A or 0x0D bytes." 133 // and contains no 0x0A or 0x0D bytes."
135 return isValidHTTPHeaderValue(value); 134 return isValidHTTPHeaderValue(value);
136 } 135 }
137 136
138 bool FetchHeaderList::isSimpleHeader(const String& name, const String& value)
139 {
140 // "A simple header is a header whose name is either one of `Accept`,
141 // `Accept-Language`, and `Content-Language`, or whose name is
142 // `Content-Type` and value, once parsed, is one of
143 // `application/x-www-form-urlencoded`, `multipart/form-data`, and
144 // `text/plain`."
145 if (equalIgnoringCase(name, "accept")
146 || equalIgnoringCase(name, "accept-language")
147 || equalIgnoringCase(name, "content-language"))
148 return true;
149
150 if (equalIgnoringCase(name, "content-type")) {
151 AtomicString mimeType = extractMIMETypeFromMediaType(AtomicString(value) );
152 return equalIgnoringCase(mimeType, "application/x-www-form-urlencoded")
153 || equalIgnoringCase(mimeType, "multipart/form-data")
154 || equalIgnoringCase(mimeType, "text/plain");
155 }
156
157 return false;
158 }
159
160 bool FetchHeaderList::isForbiddenHeaderName(const String& name)
161 {
162 // "A forbidden header name is a header names that is one of:
163 // `Accept-Charset`, `Accept-Encoding`, `Access-Control-Request-Headers`,
164 // `Access-Control-Request-Method`, `Connection`,
165 // `Content-Length, Cookie`, `Cookie2`, `Date`, `DNT`, `Expect`, `Host`,
166 // `Keep-Alive`, `Origin`, `Referer`, `TE`, `Trailer`,
167 // `Transfer-Encoding`, `Upgrade`, `User-Agent`, `Via`
168 // or starts with `Proxy-` or `Sec-` (including when it is just `Proxy-` or
169 // `Sec-`)."
170 return !XMLHttpRequest::isAllowedHTTPHeader(name) || equalIgnoringCase(name, "DNT");
171 }
172
173 bool FetchHeaderList::isForbiddenResponseHeaderName(const String& name)
174 {
175 // "A forbidden response header name is a header name that is one of:
176 // `Set-Cookie`, `Set-Cookie2`"
177 return equalIgnoringCase(name, "set-cookie") || equalIgnoringCase(name, "set -cookie2");
178 }
179
180 } // namespace WebCore 137 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698