Chromium Code Reviews| 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/Request.h" | 6 #include "modules/fetch/Request.h" |
| 7 | 7 |
| 8 #include "bindings/core/v8/Dictionary.h" | 8 #include "bindings/core/v8/Dictionary.h" |
| 9 #include "core/dom/Document.h" | 9 #include "core/dom/Document.h" |
| 10 #include "core/dom/ExecutionContext.h" | 10 #include "core/dom/ExecutionContext.h" |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 34 DOMWrapperWorld& world = scriptState->world(); | 34 DOMWrapperWorld& world = scriptState->world(); |
| 35 if (world.isIsolatedWorld()) | 35 if (world.isIsolatedWorld()) |
| 36 request->setOrigin(world.isolatedWorldSecurityOrigin()); | 36 request->setOrigin(world.isolatedWorldSecurityOrigin()); |
| 37 else | 37 else |
| 38 request->setOrigin(scriptState->executionContext()->securityOrigin()); | 38 request->setOrigin(scriptState->executionContext()->securityOrigin()); |
| 39 // FIXME: Set ForceOriginHeaderFlag. | 39 // FIXME: Set ForceOriginHeaderFlag. |
| 40 request->setSameOriginDataURLFlag(true); | 40 request->setSameOriginDataURLFlag(true); |
| 41 request->mutableReferrer()->setClient(); | 41 request->mutableReferrer()->setClient(); |
| 42 request->setMode(original->mode()); | 42 request->setMode(original->mode()); |
| 43 request->setCredentials(original->credentials()); | 43 request->setCredentials(original->credentials()); |
| 44 request->setIntegrity(original->integrity()); | |
| 44 // FIXME: Set cache mode. | 45 // FIXME: Set cache mode. |
| 45 // TODO(yhirano): Set redirect mode. | 46 // TODO(yhirano): Set redirect mode. |
| 46 return request; | 47 return request; |
| 47 } | 48 } |
| 48 | 49 |
| 49 Request* Request::createRequestWithRequestOrString(ScriptState* scriptState, Req uest* inputRequest, const String& inputString, const RequestInit& init, Exceptio nState& exceptionState) | 50 Request* Request::createRequestWithRequestOrString(ScriptState* scriptState, Req uest* inputRequest, const String& inputString, const RequestInit& init, Exceptio nState& exceptionState) |
| 50 { | 51 { |
| 51 // "1. Let |temporaryBody| be null." | 52 // "1. Let |temporaryBody| be null." |
| 52 BodyStreamBuffer* temporaryBody = nullptr; | 53 BodyStreamBuffer* temporaryBody = nullptr; |
| 53 | 54 |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 73 } | 74 } |
| 74 | 75 |
| 75 // "3. Let |request| be |input|'s request, if |input| is a Request object, | 76 // "3. Let |request| be |input|'s request, if |input| is a Request object, |
| 76 // and a new request otherwise." | 77 // and a new request otherwise." |
| 77 // "4. Set |request| to a new request whose url is |request|'s url, method | 78 // "4. Set |request| to a new request whose url is |request|'s url, method |
| 78 // is |request|'s method, header list is a copy of |request|'s header list, | 79 // is |request|'s method, header list is a copy of |request|'s header list, |
| 79 // unsafe request flag is set, client is entry settings object, origin is | 80 // unsafe request flag is set, client is entry settings object, origin is |
| 80 // entry settings object's origin, force Origin header flag is set, | 81 // entry settings object's origin, force Origin header flag is set, |
| 81 // same-origin data URL flag is set, context is the empty string, mode is | 82 // same-origin data URL flag is set, context is the empty string, mode is |
| 82 // |request|'s mode, credentials mode is |request|'s credentials mode, | 83 // |request|'s mode, credentials mode is |request|'s credentials mode, |
| 83 // cache mode is |request|'s cache mode, and redirect mode is request's | 84 // cache mode is |request|'s cache mode, redirect mode is request's |
| 84 // redirect mode." | 85 // redirect mode, and integrity metadata is |request|'s integrity metadata." |
| 85 FetchRequestData* request = createCopyOfFetchRequestDataForFetch(scriptState , inputRequest ? inputRequest->request() : FetchRequestData::create()); | 86 FetchRequestData* request = createCopyOfFetchRequestDataForFetch(scriptState , inputRequest ? inputRequest->request() : FetchRequestData::create()); |
| 86 | 87 |
| 87 // "5. Let |fallbackMode| be null." | 88 // "5. Let |fallbackMode| be null." |
| 88 // "6. Let |fallbackCredentials| be null." | 89 // "6. Let |fallbackCredentials| be null." |
| 89 // "7. Let |fallbackCache| be null." | 90 // "7. Let |fallbackCache| be null." |
| 90 // "8. Let |fallbackRedirect| be null." | 91 // "8. Let |fallbackRedirect| be null." |
| 91 // We don't use fallback values. We set these flags directly in below. | 92 // We don't use fallback values. We set these flags directly in below. |
| 92 | 93 |
| 93 // "9. If |input| is a string, run these substeps:" | 94 // "9. If |input| is a string, run these substeps:" |
| 94 if (!inputRequest) { | 95 if (!inputRequest) { |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 146 // |cache|." | 147 // |cache|." |
| 147 // TODO(yhirano): "16. If |init|'s redirect member is present and its is | 148 // TODO(yhirano): "16. If |init|'s redirect member is present and its is |
| 148 // manual, throw a TypeError." | 149 // manual, throw a TypeError." |
| 149 // TODO(yhirano): "17. Let |redirect| be |init|'s redirect member if it is | 150 // TODO(yhirano): "17. Let |redirect| be |init|'s redirect member if it is |
| 150 // present, and |fallbackRedirect| otherwise." | 151 // present, and |fallbackRedirect| otherwise." |
| 151 // TODO(yhirano): "18 If |redirect| is non-null, set |request|'s redirect | 152 // TODO(yhirano): "18 If |redirect| is non-null, set |request|'s redirect |
| 152 // mode to |redirect|." | 153 // mode to |redirect|." |
| 153 // TODO(yhirano): "19 If |request|'s redirect mode is manual, set it to | 154 // TODO(yhirano): "19 If |request|'s redirect mode is manual, set it to |
| 154 // follow." | 155 // follow." |
| 155 | 156 |
| 157 // 24. If |init|'s integrity method is present, set |request|'s integrity | |
| 158 // metadata to it. | |
| 159 // | |
| 160 // (Note that the step numbering has changed rather dramaticaly so the | |
| 161 // surrounding numbers should be corrected.) | |
|
tyoshino (SeeGerritForStatus)
2015/08/13 06:53:38
now this step is numbered 23. it seems keeping the
jww
2015/08/13 14:32:11
Sure, happy to. Should I remove the others at the
tyoshino (SeeGerritForStatus)
2015/08/13 15:02:31
Leaving them unchanged, removing all, either is fi
| |
| 162 if (!init.integrity.isNull()) | |
| 163 request->setIntegrity(init.integrity); | |
| 164 | |
| 156 // "20. If |init|'s method member is present, let |method| be it and run | 165 // "20. If |init|'s method member is present, let |method| be it and run |
| 157 // these substeps:" | 166 // these substeps:" |
| 158 if (!init.method.isNull()) { | 167 if (!init.method.isNull()) { |
| 159 // "1. If |method| is not a method or method is a forbidden method, | 168 // "1. If |method| is not a method or method is a forbidden method, |
| 160 // throw a TypeError." | 169 // throw a TypeError." |
| 161 if (!isValidHTTPToken(init.method)) { | 170 if (!isValidHTTPToken(init.method)) { |
| 162 exceptionState.throwTypeError("'" + init.method + "' is not a valid HTTP method."); | 171 exceptionState.throwTypeError("'" + init.method + "' is not a valid HTTP method."); |
| 163 return nullptr; | 172 return nullptr; |
| 164 } | 173 } |
| 165 if (FetchUtils::isForbiddenMethod(init.method)) { | 174 if (FetchUtils::isForbiddenMethod(init.method)) { |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 185 // "24. Empty |r|'s request's header list." | 194 // "24. Empty |r|'s request's header list." |
| 186 r->m_request->headerList()->clearList(); | 195 r->m_request->headerList()->clearList(); |
| 187 // "25. If |r|'s request's mode is no CORS, run these substeps: | 196 // "25. If |r|'s request's mode is no CORS, run these substeps: |
| 188 if (r->request()->mode() == WebURLRequest::FetchRequestModeNoCORS) { | 197 if (r->request()->mode() == WebURLRequest::FetchRequestModeNoCORS) { |
| 189 // "1. If |r|'s request's method is not a simple method, throw a | 198 // "1. If |r|'s request's method is not a simple method, throw a |
| 190 // TypeError." | 199 // TypeError." |
| 191 if (!FetchUtils::isSimpleMethod(r->request()->method())) { | 200 if (!FetchUtils::isSimpleMethod(r->request()->method())) { |
| 192 exceptionState.throwTypeError("'" + r->request()->method() + "' is u nsupported in no-cors mode."); | 201 exceptionState.throwTypeError("'" + r->request()->method() + "' is u nsupported in no-cors mode."); |
| 193 return nullptr; | 202 return nullptr; |
| 194 } | 203 } |
| 195 // "Set |r|'s Headers object's guard to |request-no-CORS|. | 204 // "2. If |request|'s integrity metadata is not the empty string, throw |
| 205 // a TypeError." | |
| 206 if (!request->integrity().isEmpty()) { | |
| 207 exceptionState.throwTypeError("The integrity attribute is unsupporte d in no-cors mode."); | |
| 208 return nullptr; | |
| 209 } | |
| 210 // "3. Set |r|'s Headers object's guard to |request-no-CORS|. | |
| 196 r->headers()->setGuard(Headers::RequestNoCORSGuard); | 211 r->headers()->setGuard(Headers::RequestNoCORSGuard); |
| 197 } | 212 } |
| 198 // "26. Fill |r|'s Headers object with |headers|. Rethrow any exceptions." | 213 // "26. Fill |r|'s Headers object with |headers|. Rethrow any exceptions." |
| 199 if (init.headers) { | 214 if (init.headers) { |
| 200 ASSERT(init.headersDictionary.isUndefinedOrNull()); | 215 ASSERT(init.headersDictionary.isUndefinedOrNull()); |
| 201 r->headers()->fillWith(init.headers.get(), exceptionState); | 216 r->headers()->fillWith(init.headers.get(), exceptionState); |
| 202 } else if (!init.headersDictionary.isUndefinedOrNull()) { | 217 } else if (!init.headersDictionary.isUndefinedOrNull()) { |
| 203 r->headers()->fillWith(init.headersDictionary, exceptionState); | 218 r->headers()->fillWith(init.headersDictionary, exceptionState); |
| 204 } else { | 219 } else { |
| 205 ASSERT(headers); | 220 ASSERT(headers); |
| (...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 446 return "omit"; | 461 return "omit"; |
| 447 case WebURLRequest::FetchCredentialsModeSameOrigin: | 462 case WebURLRequest::FetchCredentialsModeSameOrigin: |
| 448 return "same-origin"; | 463 return "same-origin"; |
| 449 case WebURLRequest::FetchCredentialsModeInclude: | 464 case WebURLRequest::FetchCredentialsModeInclude: |
| 450 return "include"; | 465 return "include"; |
| 451 } | 466 } |
| 452 ASSERT_NOT_REACHED(); | 467 ASSERT_NOT_REACHED(); |
| 453 return ""; | 468 return ""; |
| 454 } | 469 } |
| 455 | 470 |
| 471 String Request::integrity() const | |
| 472 { | |
| 473 return m_request->integrity(); | |
| 474 } | |
| 475 | |
| 456 Request* Request::clone(ExceptionState& exceptionState) | 476 Request* Request::clone(ExceptionState& exceptionState) |
| 457 { | 477 { |
| 458 if (bodyUsed()) { | 478 if (bodyUsed()) { |
| 459 exceptionState.throwTypeError("Request body is already used"); | 479 exceptionState.throwTypeError("Request body is already used"); |
| 460 return nullptr; | 480 return nullptr; |
| 461 } | 481 } |
| 462 | 482 |
| 463 FetchRequestData* request = m_request->clone(executionContext()); | 483 FetchRequestData* request = m_request->clone(executionContext()); |
| 464 Headers* headers = Headers::create(request->headerList()); | 484 Headers* headers = Headers::create(request->headerList()); |
| 465 headers->setGuard(m_headers->guard()); | 485 headers->setGuard(m_headers->guard()); |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 503 } | 523 } |
| 504 | 524 |
| 505 DEFINE_TRACE(Request) | 525 DEFINE_TRACE(Request) |
| 506 { | 526 { |
| 507 Body::trace(visitor); | 527 Body::trace(visitor); |
| 508 visitor->trace(m_request); | 528 visitor->trace(m_request); |
| 509 visitor->trace(m_headers); | 529 visitor->trace(m_headers); |
| 510 } | 530 } |
| 511 | 531 |
| 512 } // namespace blink | 532 } // namespace blink |
| OLD | NEW |