| 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 "Request.h" | 6 #include "Request.h" |
| 7 | 7 |
| 8 #include "bindings/core/v8/Dictionary.h" | 8 #include "bindings/core/v8/Dictionary.h" |
| 9 #include "core/dom/ExecutionContext.h" | 9 #include "core/dom/ExecutionContext.h" |
| 10 #include "core/fetch/CrossOriginAccessControl.h" | 10 #include "core/fetch/FetchUtils.h" |
| 11 #include "core/fetch/ResourceLoaderOptions.h" | 11 #include "core/fetch/ResourceLoaderOptions.h" |
| 12 #include "core/loader/ThreadableLoader.h" | 12 #include "core/loader/ThreadableLoader.h" |
| 13 #include "core/xml/XMLHttpRequest.h" | 13 #include "core/xml/XMLHttpRequest.h" |
| 14 #include "modules/serviceworkers/FetchManager.h" | 14 #include "modules/serviceworkers/FetchManager.h" |
| 15 #include "modules/serviceworkers/RequestInit.h" | 15 #include "modules/serviceworkers/RequestInit.h" |
| 16 #include "platform/NotImplemented.h" | 16 #include "platform/NotImplemented.h" |
| 17 #include "platform/network/HTTPParsers.h" | 17 #include "platform/network/HTTPParsers.h" |
| 18 #include "platform/network/ResourceRequest.h" | 18 #include "platform/network/ResourceRequest.h" |
| 19 #include "platform/weborigin/Referrer.h" | 19 #include "platform/weborigin/Referrer.h" |
| 20 #include "public/platform/WebServiceWorkerRequest.h" | 20 #include "public/platform/WebServiceWorkerRequest.h" |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 } else { | 53 } else { |
| 54 // Instead of using null as a special fallback value, we pass the | 54 // Instead of using null as a special fallback value, we pass the |
| 55 // current credentials in Request::create(). So we just set here. | 55 // current credentials in Request::create(). So we just set here. |
| 56 request->setCredentials(credentials); | 56 request->setCredentials(credentials); |
| 57 } | 57 } |
| 58 | 58 |
| 59 // "10. If |init|'s method member is present, let |method| be it and run | 59 // "10. If |init|'s method member is present, let |method| be it and run |
| 60 // these substeps:" | 60 // these substeps:" |
| 61 if (!init.method.isEmpty()) { | 61 if (!init.method.isEmpty()) { |
| 62 // "1. If |method| is not a useful method, throw a TypeError." | 62 // "1. If |method| is not a useful method, throw a TypeError." |
| 63 if (!FetchManager::isUsefulMethod(init.method)) { | 63 if (!FetchUtils::isUsefulMethod(init.method)) { |
| 64 exceptionState.throwTypeError("'" + init.method + "' HTTP method is
unsupported."); | 64 exceptionState.throwTypeError("'" + init.method + "' HTTP method is
unsupported."); |
| 65 return nullptr; | 65 return nullptr; |
| 66 } | 66 } |
| 67 if (!isValidHTTPToken(init.method)) { | 67 if (!isValidHTTPToken(init.method)) { |
| 68 exceptionState.throwTypeError("'" + init.method + "' is not a valid
HTTP method."); | 68 exceptionState.throwTypeError("'" + init.method + "' is not a valid
HTTP method."); |
| 69 return nullptr; | 69 return nullptr; |
| 70 } | 70 } |
| 71 // FIXME: "2. Add case correction as in XMLHttpRequest?" | 71 // FIXME: "2. Add case correction as in XMLHttpRequest?" |
| 72 // "3. Set |request|'s method to |method|." | 72 // "3. Set |request|'s method to |method|." |
| 73 request->setMethod(XMLHttpRequest::uppercaseKnownHTTPMethod(AtomicString
(init.method))); | 73 request->setMethod(XMLHttpRequest::uppercaseKnownHTTPMethod(AtomicString
(init.method))); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 85 if (!init.headers && init.headersDictionary.isUndefinedOrNull()) { | 85 if (!init.headers && init.headersDictionary.isUndefinedOrNull()) { |
| 86 headers = r->headers()->createCopy(); | 86 headers = r->headers()->createCopy(); |
| 87 } | 87 } |
| 88 // "14. Empty |r|'s request's header list." | 88 // "14. Empty |r|'s request's header list." |
| 89 r->request()->headerList()->clearList(); | 89 r->request()->headerList()->clearList(); |
| 90 | 90 |
| 91 // "15. If |r|'s request's mode is no CORS, run these substeps: | 91 // "15. If |r|'s request's mode is no CORS, run these substeps: |
| 92 if (r->request()->mode() == FetchRequestData::NoCORSMode) { | 92 if (r->request()->mode() == FetchRequestData::NoCORSMode) { |
| 93 // "1. If |r|'s request's method is not a simple method, throw a | 93 // "1. If |r|'s request's method is not a simple method, throw a |
| 94 // TypeError." | 94 // TypeError." |
| 95 if (!FetchManager::isSimpleMethod(r->request()->method())) { | 95 if (!FetchUtils::isSimpleMethod(r->request()->method())) { |
| 96 exceptionState.throwTypeError("'" + r->request()->method() + "' is u
nsupported in no-cors mode."); | 96 exceptionState.throwTypeError("'" + r->request()->method() + "' is u
nsupported in no-cors mode."); |
| 97 return nullptr; | 97 return nullptr; |
| 98 } | 98 } |
| 99 // "Set |r|'s Headers object's guard to |request-no-CORS|. | 99 // "Set |r|'s Headers object's guard to |request-no-CORS|. |
| 100 r->headers()->setGuard(Headers::RequestNoCORSGuard); | 100 r->headers()->setGuard(Headers::RequestNoCORSGuard); |
| 101 } | 101 } |
| 102 | 102 |
| 103 // "16. Fill |r|'s Headers object with |headers|. Rethrow any exceptions." | 103 // "16. Fill |r|'s Headers object with |headers|. Rethrow any exceptions." |
| 104 if (init.headers) { | 104 if (init.headers) { |
| 105 ASSERT(init.headersDictionary.isUndefinedOrNull()); | 105 ASSERT(init.headersDictionary.isUndefinedOrNull()); |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 255 return ""; | 255 return ""; |
| 256 } | 256 } |
| 257 | 257 |
| 258 void Request::trace(Visitor* visitor) | 258 void Request::trace(Visitor* visitor) |
| 259 { | 259 { |
| 260 visitor->trace(m_request); | 260 visitor->trace(m_request); |
| 261 visitor->trace(m_headers); | 261 visitor->trace(m_headers); |
| 262 } | 262 } |
| 263 | 263 |
| 264 } // namespace blink | 264 } // namespace blink |
| OLD | NEW |