| 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 24 matching lines...) Expand all Loading... |
| 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->setRedirect(original->redirect()); | 44 request->setRedirect(original->redirect()); |
| 45 request->setIntegrity(original->integrity()); |
| 45 // FIXME: Set cache mode. | 46 // FIXME: Set cache mode. |
| 46 // TODO(yhirano): Set redirect mode. | 47 // TODO(yhirano): Set redirect mode. |
| 47 return request; | 48 return request; |
| 48 } | 49 } |
| 49 | 50 |
| 50 Request* Request::createRequestWithRequestOrString(ScriptState* scriptState, Req
uest* inputRequest, const String& inputString, const RequestInit& init, Exceptio
nState& exceptionState) | 51 Request* Request::createRequestWithRequestOrString(ScriptState* scriptState, Req
uest* inputRequest, const String& inputString, const RequestInit& init, Exceptio
nState& exceptionState) |
| 51 { | 52 { |
| 52 // "1. Let |temporaryBody| be null." | 53 // "1. Let |temporaryBody| be null." |
| 53 BodyStreamBuffer* temporaryBody = nullptr; | 54 BodyStreamBuffer* temporaryBody = nullptr; |
| 54 | 55 |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 152 if (!inputRequest) | 153 if (!inputRequest) |
| 153 request->setCredentials(WebURLRequest::FetchCredentialsModeOmit); | 154 request->setCredentials(WebURLRequest::FetchCredentialsModeOmit); |
| 154 } | 155 } |
| 155 | 156 |
| 156 // TODO(yhirano): "21. If |init|'s cache member is present, set |request|'s | 157 // TODO(yhirano): "21. If |init|'s cache member is present, set |request|'s |
| 157 // cache mode to it." | 158 // cache mode to it." |
| 158 | 159 |
| 159 // TODO(horo): "22. If |init|'s redirect member is present, set |request|'s | 160 // TODO(horo): "22. If |init|'s redirect member is present, set |request|'s |
| 160 // redirect mode to it." | 161 // redirect mode to it." |
| 161 | 162 |
| 162 // TODO(jww): "23. If |init|'s integrity member is present, set |request|'s | 163 // "If |init|'s integrity member is present, set |request|'s |
| 163 // integrity metadata to it." | 164 // integrity metadata to it." |
| 164 | 165 |
| 166 if (!init.integrity.isNull()) |
| 167 request->setIntegrity(init.integrity); |
| 168 |
| 165 // "24. If |init|'s method member is present, let |method| be it and run | 169 // "24. If |init|'s method member is present, let |method| be it and run |
| 166 // these substeps:" | 170 // these substeps:" |
| 167 if (!init.method.isNull()) { | 171 if (!init.method.isNull()) { |
| 168 // "1. If |method| is not a method or method is a forbidden method, | 172 // "1. If |method| is not a method or method is a forbidden method, |
| 169 // throw a TypeError." | 173 // throw a TypeError." |
| 170 if (!isValidHTTPToken(init.method)) { | 174 if (!isValidHTTPToken(init.method)) { |
| 171 exceptionState.throwTypeError("'" + init.method + "' is not a valid
HTTP method."); | 175 exceptionState.throwTypeError("'" + init.method + "' is not a valid
HTTP method."); |
| 172 return nullptr; | 176 return nullptr; |
| 173 } | 177 } |
| 174 if (FetchUtils::isForbiddenMethod(init.method)) { | 178 if (FetchUtils::isForbiddenMethod(init.method)) { |
| (...skipping 19 matching lines...) Expand all Loading... |
| 194 // "28. Empty |r|'s request's header list." | 198 // "28. Empty |r|'s request's header list." |
| 195 r->m_request->headerList()->clearList(); | 199 r->m_request->headerList()->clearList(); |
| 196 // "29. If |r|'s request's mode is no CORS, run these substeps: | 200 // "29. If |r|'s request's mode is no CORS, run these substeps: |
| 197 if (r->request()->mode() == WebURLRequest::FetchRequestModeNoCORS) { | 201 if (r->request()->mode() == WebURLRequest::FetchRequestModeNoCORS) { |
| 198 // "1. If |r|'s request's method is not a simple method, throw a | 202 // "1. If |r|'s request's method is not a simple method, throw a |
| 199 // TypeError." | 203 // TypeError." |
| 200 if (!FetchUtils::isSimpleMethod(r->request()->method())) { | 204 if (!FetchUtils::isSimpleMethod(r->request()->method())) { |
| 201 exceptionState.throwTypeError("'" + r->request()->method() + "' is u
nsupported in no-cors mode."); | 205 exceptionState.throwTypeError("'" + r->request()->method() + "' is u
nsupported in no-cors mode."); |
| 202 return nullptr; | 206 return nullptr; |
| 203 } | 207 } |
| 204 // "Set |r|'s Headers object's guard to |request-no-CORS|. | 208 // "2. If |request|'s integrity metadata is not the empty string, throw |
| 209 // a TypeError." |
| 210 if (!request->integrity().isEmpty()) { |
| 211 exceptionState.throwTypeError("The integrity attribute is unsupporte
d in no-cors mode."); |
| 212 return nullptr; |
| 213 } |
| 214 // "3. Set |r|'s Headers object's guard to |request-no-CORS|. |
| 205 r->headers()->setGuard(Headers::RequestNoCORSGuard); | 215 r->headers()->setGuard(Headers::RequestNoCORSGuard); |
| 206 } | 216 } |
| 207 // "30. Fill |r|'s Headers object with |headers|. Rethrow any exceptions." | 217 // "30. Fill |r|'s Headers object with |headers|. Rethrow any exceptions." |
| 208 if (init.headers) { | 218 if (init.headers) { |
| 209 ASSERT(init.headersDictionary.isUndefinedOrNull()); | 219 ASSERT(init.headersDictionary.isUndefinedOrNull()); |
| 210 r->headers()->fillWith(init.headers.get(), exceptionState); | 220 r->headers()->fillWith(init.headers.get(), exceptionState); |
| 211 } else if (!init.headersDictionary.isUndefinedOrNull()) { | 221 } else if (!init.headersDictionary.isUndefinedOrNull()) { |
| 212 r->headers()->fillWith(init.headersDictionary, exceptionState); | 222 r->headers()->fillWith(init.headersDictionary, exceptionState); |
| 213 } else { | 223 } else { |
| 214 ASSERT(headers); | 224 ASSERT(headers); |
| (...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 470 return "follow"; | 480 return "follow"; |
| 471 case WebURLRequest::FetchRedirectModeError: | 481 case WebURLRequest::FetchRedirectModeError: |
| 472 return "error"; | 482 return "error"; |
| 473 case WebURLRequest::FetchRedirectModeManual: | 483 case WebURLRequest::FetchRedirectModeManual: |
| 474 return "manual"; | 484 return "manual"; |
| 475 } | 485 } |
| 476 ASSERT_NOT_REACHED(); | 486 ASSERT_NOT_REACHED(); |
| 477 return ""; | 487 return ""; |
| 478 } | 488 } |
| 479 | 489 |
| 490 String Request::integrity() const |
| 491 { |
| 492 return m_request->integrity(); |
| 493 } |
| 494 |
| 480 Request* Request::clone(ExceptionState& exceptionState) | 495 Request* Request::clone(ExceptionState& exceptionState) |
| 481 { | 496 { |
| 482 if (bodyUsed()) { | 497 if (bodyUsed()) { |
| 483 exceptionState.throwTypeError("Request body is already used"); | 498 exceptionState.throwTypeError("Request body is already used"); |
| 484 return nullptr; | 499 return nullptr; |
| 485 } | 500 } |
| 486 | 501 |
| 487 FetchRequestData* request = m_request->clone(executionContext()); | 502 FetchRequestData* request = m_request->clone(executionContext()); |
| 488 Headers* headers = Headers::create(request->headerList()); | 503 Headers* headers = Headers::create(request->headerList()); |
| 489 headers->setGuard(m_headers->guard()); | 504 headers->setGuard(m_headers->guard()); |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 527 } | 542 } |
| 528 | 543 |
| 529 DEFINE_TRACE(Request) | 544 DEFINE_TRACE(Request) |
| 530 { | 545 { |
| 531 Body::trace(visitor); | 546 Body::trace(visitor); |
| 532 visitor->trace(m_request); | 547 visitor->trace(m_request); |
| 533 visitor->trace(m_headers); | 548 visitor->trace(m_headers); |
| 534 } | 549 } |
| 535 | 550 |
| 536 } // namespace blink | 551 } // namespace blink |
| OLD | NEW |