| 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/CrossOriginAccessControl.h" |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 } else { | 54 } else { |
| 55 // Instead of using null as a special fallback value, we pass the | 55 // Instead of using null as a special fallback value, we pass the |
| 56 // current credentials in Request::create(). So we just set here. | 56 // current credentials in Request::create(). So we just set here. |
| 57 request->setCredentials(credentials); | 57 request->setCredentials(credentials); |
| 58 } | 58 } |
| 59 | 59 |
| 60 // "10. If |init|'s method member is present, let |method| be it and run | 60 // "10. If |init|'s method member is present, let |method| be it and run |
| 61 // these substeps:" | 61 // these substeps:" |
| 62 if (!init.method.isEmpty()) { | 62 if (!init.method.isEmpty()) { |
| 63 // "1. If |method| is not a useful method, throw a TypeError." | 63 // "1. If |method| is not a useful method, throw a TypeError." |
| 64 if (!FetchManager::isUsefulMethod(init.method)) { | 64 if (!CrossOriginAccessControl::isUsefulMethod(init.method)) { |
| 65 exceptionState.throwTypeError("'" + init.method + "' HTTP method is
unsupported."); | 65 exceptionState.throwTypeError("'" + init.method + "' HTTP method is
unsupported."); |
| 66 return nullptr; | 66 return nullptr; |
| 67 } | 67 } |
| 68 if (!isValidHTTPToken(init.method)) { | 68 if (!isValidHTTPToken(init.method)) { |
| 69 exceptionState.throwTypeError("'" + init.method + "' is not a valid
HTTP method."); | 69 exceptionState.throwTypeError("'" + init.method + "' is not a valid
HTTP method."); |
| 70 return nullptr; | 70 return nullptr; |
| 71 } | 71 } |
| 72 // FIXME: "2. Add case correction as in XMLHttpRequest?" | 72 // FIXME: "2. Add case correction as in XMLHttpRequest?" |
| 73 // "3. Set |request|'s method to |method|." | 73 // "3. Set |request|'s method to |method|." |
| 74 request->setMethod(XMLHttpRequest::uppercaseKnownHTTPMethod(AtomicString
(init.method))); | 74 request->setMethod(XMLHttpRequest::uppercaseKnownHTTPMethod(AtomicString
(init.method))); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 86 if (!init.headers && init.headersDictionary.isUndefinedOrNull()) { | 86 if (!init.headers && init.headersDictionary.isUndefinedOrNull()) { |
| 87 headers = r->headers()->createCopy(); | 87 headers = r->headers()->createCopy(); |
| 88 } | 88 } |
| 89 // "14. Empty |r|'s request's header list." | 89 // "14. Empty |r|'s request's header list." |
| 90 r->request()->headerList()->clearList(); | 90 r->request()->headerList()->clearList(); |
| 91 | 91 |
| 92 // "15. If |r|'s request's mode is no CORS, run these substeps: | 92 // "15. If |r|'s request's mode is no CORS, run these substeps: |
| 93 if (r->request()->mode() == FetchRequestData::NoCORSMode) { | 93 if (r->request()->mode() == FetchRequestData::NoCORSMode) { |
| 94 // "1. If |r|'s request's method is not a simple method, throw a | 94 // "1. If |r|'s request's method is not a simple method, throw a |
| 95 // TypeError." | 95 // TypeError." |
| 96 if (!FetchManager::isSimpleMethod(r->request()->method())) { | 96 if (!CrossOriginAccessControl::isSimpleMethod(r->request()->method())) { |
| 97 exceptionState.throwTypeError("'" + r->request()->method() + "' is u
nsupported in no-cors mode."); | 97 exceptionState.throwTypeError("'" + r->request()->method() + "' is u
nsupported in no-cors mode."); |
| 98 return nullptr; | 98 return nullptr; |
| 99 } | 99 } |
| 100 // "Set |r|'s Headers object's guard to |request-no-CORS|. | 100 // "Set |r|'s Headers object's guard to |request-no-CORS|. |
| 101 r->headers()->setGuard(Headers::RequestNoCORSGuard); | 101 r->headers()->setGuard(Headers::RequestNoCORSGuard); |
| 102 } | 102 } |
| 103 | 103 |
| 104 // "16. Fill |r|'s Headers object with |headers|. Rethrow any exceptions." | 104 // "16. Fill |r|'s Headers object with |headers|. Rethrow any exceptions." |
| 105 if (init.headers) { | 105 if (init.headers) { |
| 106 ASSERT(init.headersDictionary.isUndefinedOrNull()); | 106 ASSERT(init.headersDictionary.isUndefinedOrNull()); |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 265 return request.release(); | 265 return request.release(); |
| 266 } | 266 } |
| 267 | 267 |
| 268 void Request::trace(Visitor* visitor) | 268 void Request::trace(Visitor* visitor) |
| 269 { | 269 { |
| 270 visitor->trace(m_request); | 270 visitor->trace(m_request); |
| 271 visitor->trace(m_headers); | 271 visitor->trace(m_headers); |
| 272 } | 272 } |
| 273 | 273 |
| 274 } // namespace WebCore | 274 } // namespace WebCore |
| OLD | NEW |