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 "FetchManager.h" | 6 #include "FetchManager.h" |
7 | 7 |
8 #include "bindings/core/v8/ExceptionState.h" | 8 #include "bindings/core/v8/ExceptionState.h" |
9 #include "bindings/core/v8/ScriptPromiseResolver.h" | 9 #include "bindings/core/v8/ScriptPromiseResolver.h" |
10 #include "bindings/core/v8/ScriptState.h" | 10 #include "bindings/core/v8/ScriptState.h" |
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
168 // "- |request|'s url's scheme is 'about'" | 168 // "- |request|'s url's scheme is 'about'" |
169 if ((SecurityOrigin::create(m_request->url())->isSameSchemeHostPort(m_reques
t->origin().get()) && !m_corsFlag) | 169 if ((SecurityOrigin::create(m_request->url())->isSameSchemeHostPort(m_reques
t->origin().get()) && !m_corsFlag) |
170 || (m_request->url().protocolIsData() && m_request->sameOriginDataURLFla
g()) | 170 || (m_request->url().protocolIsData() && m_request->sameOriginDataURLFla
g()) |
171 || (m_request->url().protocolIsAbout())) { | 171 || (m_request->url().protocolIsAbout())) { |
172 // "The result of performing a basic fetch using request." | 172 // "The result of performing a basic fetch using request." |
173 performBasicFetch(); | 173 performBasicFetch(); |
174 return; | 174 return; |
175 } | 175 } |
176 | 176 |
177 // "- |request|'s mode is |same-origin|" | 177 // "- |request|'s mode is |same-origin|" |
178 if (m_request->mode() == FetchRequestData::SameOriginMode) { | 178 if (m_request->mode() == WebURLRequest::FetchRequestModeSameOrigin) { |
179 // "A network error." | 179 // "A network error." |
180 performNetworkError(); | 180 performNetworkError(); |
181 return; | 181 return; |
182 } | 182 } |
183 | 183 |
184 // "- |request|'s mode is |no CORS|" | 184 // "- |request|'s mode is |no CORS|" |
185 if (m_request->mode() == FetchRequestData::NoCORSMode) { | 185 if (m_request->mode() == WebURLRequest::FetchRequestModeNoCORS) { |
186 // "Set |request|'s response tainting to |opaque|." | 186 // "Set |request|'s response tainting to |opaque|." |
187 m_request->setResponseTainting(FetchRequestData::OpaqueTainting); | 187 m_request->setResponseTainting(FetchRequestData::OpaqueTainting); |
188 // "The result of performing a basic fetch using |request|." | 188 // "The result of performing a basic fetch using |request|." |
189 performBasicFetch(); | 189 performBasicFetch(); |
190 return; | 190 return; |
191 } | 191 } |
192 | 192 |
193 // "- |request|'s url's scheme is not one of 'http' and 'https'" | 193 // "- |request|'s url's scheme is not one of 'http' and 'https'" |
194 if (!m_request->url().protocolIsInHTTPFamily()) { | 194 if (!m_request->url().protocolIsInHTTPFamily()) { |
195 // "A network error." | 195 // "A network error." |
196 performNetworkError(); | 196 performNetworkError(); |
197 return; | 197 return; |
198 } | 198 } |
199 | 199 |
200 // "- |request|'s mode is |CORS-with-forced-preflight|. | 200 // "- |request|'s mode is |CORS-with-forced-preflight|. |
201 // "- |request|'s unsafe request flag is set and either |request|'s method | 201 // "- |request|'s unsafe request flag is set and either |request|'s method |
202 // is not a simple method or a header in |request|'s header list is not a | 202 // is not a simple method or a header in |request|'s header list is not a |
203 // simple header" | 203 // simple header" |
204 if (m_request->mode() == FetchRequestData::CORSWithForcedPreflight | 204 if (m_request->mode() == WebURLRequest::FetchRequestModeCORSWithForcedPrefli
ght |
205 || (m_request->unsafeRequestFlag() | 205 || (m_request->unsafeRequestFlag() |
206 && (!FetchUtils::isSimpleMethod(m_request->method()) | 206 && (!FetchUtils::isSimpleMethod(m_request->method()) |
207 || m_request->headerList()->containsNonSimpleHeader()))) { | 207 || m_request->headerList()->containsNonSimpleHeader()))) { |
208 // "Set |request|'s response tainting to |CORS|." | 208 // "Set |request|'s response tainting to |CORS|." |
209 m_request->setResponseTainting(FetchRequestData::CORSTainting); | 209 m_request->setResponseTainting(FetchRequestData::CORSTainting); |
210 // "The result of performing an HTTP fetch using |request| with the | 210 // "The result of performing an HTTP fetch using |request| with the |
211 // |CORS flag| and |CORS preflight flag| set." | 211 // |CORS flag| and |CORS preflight flag| set." |
212 m_corsFlag = true; | 212 m_corsFlag = true; |
213 m_corsPreflightFlag = true; | 213 m_corsPreflightFlag = true; |
214 performHTTPFetch(); | 214 performHTTPFetch(); |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
296 // |HTTPRequest|'s origin, serialized and utf-8 encoded, to |HTTPRequest|'s | 296 // |HTTPRequest|'s origin, serialized and utf-8 encoded, to |HTTPRequest|'s |
297 // header list." | 297 // header list." |
298 // We set Origin header in updateRequestForAccessControl() called from | 298 // We set Origin header in updateRequestForAccessControl() called from |
299 // DocumentThreadableLoader::makeCrossOriginAccessRequest | 299 // DocumentThreadableLoader::makeCrossOriginAccessRequest |
300 | 300 |
301 // "5. Let |credentials flag| be set if either |HTTPRequest|'s credentials | 301 // "5. Let |credentials flag| be set if either |HTTPRequest|'s credentials |
302 // mode is |include|, or |HTTPRequest|'s credentials mode is |same-origin| | 302 // mode is |include|, or |HTTPRequest|'s credentials mode is |same-origin| |
303 // and the |CORS flag| is unset, and unset otherwise. | 303 // and the |CORS flag| is unset, and unset otherwise. |
304 ResourceLoaderOptions resourceLoaderOptions; | 304 ResourceLoaderOptions resourceLoaderOptions; |
305 resourceLoaderOptions.dataBufferingPolicy = DoNotBufferData; | 305 resourceLoaderOptions.dataBufferingPolicy = DoNotBufferData; |
306 if (m_request->credentials() == FetchRequestData::IncludeCredentials | 306 if (m_request->credentials() == WebURLRequest::FetchCredentialsModeInclude |
307 || (m_request->credentials() == FetchRequestData::SameOriginCredentials
&& !m_corsFlag)) { | 307 || (m_request->credentials() == WebURLRequest::FetchCredentialsModeSameO
rigin && !m_corsFlag)) { |
308 resourceLoaderOptions.allowCredentials = AllowStoredCredentials; | 308 resourceLoaderOptions.allowCredentials = AllowStoredCredentials; |
309 } | 309 } |
310 | 310 |
311 ThreadableLoaderOptions threadableLoaderOptions; | 311 ThreadableLoaderOptions threadableLoaderOptions; |
312 if (m_corsPreflightFlag) | 312 if (m_corsPreflightFlag) |
313 threadableLoaderOptions.preflightPolicy = ForcePreflight; | 313 threadableLoaderOptions.preflightPolicy = ForcePreflight; |
314 if (m_corsFlag) | 314 if (m_corsFlag) |
315 threadableLoaderOptions.crossOriginRequestPolicy = UseAccessControl; | 315 threadableLoaderOptions.crossOriginRequestPolicy = UseAccessControl; |
316 else | 316 else |
317 threadableLoaderOptions.crossOriginRequestPolicy = AllowCrossOriginReque
sts; | 317 threadableLoaderOptions.crossOriginRequestPolicy = AllowCrossOriginReque
sts; |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
361 loader->start(); | 361 loader->start(); |
362 return promise; | 362 return promise; |
363 } | 363 } |
364 | 364 |
365 void FetchManager::onLoaderFinished(Loader* loader) | 365 void FetchManager::onLoaderFinished(Loader* loader) |
366 { | 366 { |
367 m_loaders.remove(loader); | 367 m_loaders.remove(loader); |
368 } | 368 } |
369 | 369 |
370 } // namespace blink | 370 } // namespace blink |
OLD | NEW |