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 "modules/fetch/FetchManager.h" | 6 #include "modules/fetch/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 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
278 // "- |request|'s mode is |CORS-with-forced-preflight|. | 278 // "- |request|'s mode is |CORS-with-forced-preflight|. |
279 // "- |request|'s unsafe request flag is set and either |request|'s method | 279 // "- |request|'s unsafe request flag is set and either |request|'s method |
280 // is not a simple method or a header in |request|'s header list is not a | 280 // is not a simple method or a header in |request|'s header list is not a |
281 // simple header" | 281 // simple header" |
282 if (m_request->mode() == WebURLRequest::FetchRequestModeCORSWithForcedPrefli
ght | 282 if (m_request->mode() == WebURLRequest::FetchRequestModeCORSWithForcedPrefli
ght |
283 || (m_request->unsafeRequestFlag() | 283 || (m_request->unsafeRequestFlag() |
284 && (!FetchUtils::isSimpleMethod(m_request->method()) | 284 && (!FetchUtils::isSimpleMethod(m_request->method()) |
285 || m_request->headerList()->containsNonSimpleHeader()))) { | 285 || m_request->headerList()->containsNonSimpleHeader()))) { |
286 // "Set |request|'s response tainting to |CORS|." | 286 // "Set |request|'s response tainting to |CORS|." |
287 m_request->setResponseTainting(FetchRequestData::CORSTainting); | 287 m_request->setResponseTainting(FetchRequestData::CORSTainting); |
| 288 m_request->setRedirect(WebURLRequest::FetchRedirectModeError); |
288 // "The result of performing an HTTP fetch using |request| with the | 289 // "The result of performing an HTTP fetch using |request| with the |
289 // |CORS flag| and |CORS preflight flag| set." | 290 // |CORS flag| and |CORS preflight flag| set." |
290 performHTTPFetch(true, true); | 291 performHTTPFetch(true, true); |
291 return; | 292 return; |
292 } | 293 } |
293 | 294 |
294 // "- Otherwise | 295 // "- Otherwise |
295 // Set |request|'s response tainting to |CORS|." | 296 // Set |request|'s response tainting to |CORS|." |
296 m_request->setResponseTainting(FetchRequestData::CORSTainting); | 297 m_request->setResponseTainting(FetchRequestData::CORSTainting); |
297 // "The result of performing an HTTP fetch using |request| with the | 298 // "The result of performing an HTTP fetch using |request| with the |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
354 { | 355 { |
355 ASSERT(m_request->url().protocolIsInHTTPFamily()); | 356 ASSERT(m_request->url().protocolIsInHTTPFamily()); |
356 // CORS preflight fetch procedure is implemented inside DocumentThreadableLo
ader. | 357 // CORS preflight fetch procedure is implemented inside DocumentThreadableLo
ader. |
357 | 358 |
358 // "1. Let |HTTPRequest| be a copy of |request|, except that |HTTPRequest|'s | 359 // "1. Let |HTTPRequest| be a copy of |request|, except that |HTTPRequest|'s |
359 // body is a tee of |request|'s body." | 360 // body is a tee of |request|'s body." |
360 // We use ResourceRequest class for HTTPRequest. | 361 // We use ResourceRequest class for HTTPRequest. |
361 // FIXME: Support body. | 362 // FIXME: Support body. |
362 ResourceRequest request(m_request->url()); | 363 ResourceRequest request(m_request->url()); |
363 request.setRequestContext(m_request->context()); | 364 request.setRequestContext(m_request->context()); |
| 365 request.setFetchRedirectMode(m_request->redirect()); |
364 request.setHTTPMethod(m_request->method()); | 366 request.setHTTPMethod(m_request->method()); |
365 const Vector<OwnPtr<FetchHeaderList::Header>>& list = m_request->headerList(
)->list(); | 367 const Vector<OwnPtr<FetchHeaderList::Header>>& list = m_request->headerList(
)->list(); |
366 for (size_t i = 0; i < list.size(); ++i) { | 368 for (size_t i = 0; i < list.size(); ++i) { |
367 request.addHTTPHeaderField(AtomicString(list[i]->first), AtomicString(li
st[i]->second)); | 369 request.addHTTPHeaderField(AtomicString(list[i]->first), AtomicString(li
st[i]->second)); |
368 } | 370 } |
369 | 371 |
370 if (m_request->method() != "GET" && m_request->method() != "HEAD") { | 372 if (m_request->method() != "GET" && m_request->method() != "HEAD") { |
371 RefPtr<BlobDataHandle> blobDataHandle = m_request->blobDataHandle(); | 373 RefPtr<BlobDataHandle> blobDataHandle = m_request->blobDataHandle(); |
372 if (blobDataHandle.get()) { | 374 if (blobDataHandle.get()) { |
373 RefPtr<FormData> httpBody(FormData::create()); | 375 RefPtr<FormData> httpBody(FormData::create()); |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
495 | 497 |
496 DEFINE_TRACE(FetchManager) | 498 DEFINE_TRACE(FetchManager) |
497 { | 499 { |
498 #if ENABLE(OILPAN) | 500 #if ENABLE(OILPAN) |
499 visitor->trace(m_executionContext); | 501 visitor->trace(m_executionContext); |
500 visitor->trace(m_loaders); | 502 visitor->trace(m_loaders); |
501 #endif | 503 #endif |
502 } | 504 } |
503 | 505 |
504 } // namespace blink | 506 } // namespace blink |
OLD | NEW |