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, RequestInit& init, ExceptionState
& exceptionState) | 51 Request* Request::createRequestWithRequestOrString(ScriptState* scriptState, Req
uest* inputRequest, const String& inputString, RequestInit& init, ExceptionState
& 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 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
159 // "22. If |init|'s redirect member is present, set |request|'s redirect | 160 // "22. If |init|'s redirect member is present, set |request|'s redirect |
160 // mode to it." | 161 // mode to it." |
161 if (init.redirect == "follow") { | 162 if (init.redirect == "follow") { |
162 request->setRedirect(WebURLRequest::FetchRedirectModeFollow); | 163 request->setRedirect(WebURLRequest::FetchRedirectModeFollow); |
163 } else if (init.redirect == "error") { | 164 } else if (init.redirect == "error") { |
164 request->setRedirect(WebURLRequest::FetchRedirectModeError); | 165 request->setRedirect(WebURLRequest::FetchRedirectModeError); |
165 } else if (init.redirect == "manual") { | 166 } else if (init.redirect == "manual") { |
166 request->setRedirect(WebURLRequest::FetchRedirectModeManual); | 167 request->setRedirect(WebURLRequest::FetchRedirectModeManual); |
167 } | 168 } |
168 | 169 |
169 // TODO(jww): "23. If |init|'s integrity member is present, set |request|'s | 170 // "If |init|'s integrity member is present, set |request|'s |
170 // integrity metadata to it." | 171 // integrity metadata to it." |
| 172 if (!init.integrity.isNull()) |
| 173 request->setIntegrity(init.integrity); |
171 | 174 |
172 // "24. If |init|'s method member is present, let |method| be it and run | 175 // "24. If |init|'s method member is present, let |method| be it and run |
173 // these substeps:" | 176 // these substeps:" |
174 if (!init.method.isNull()) { | 177 if (!init.method.isNull()) { |
175 // "1. If |method| is not a method or method is a forbidden method, | 178 // "1. If |method| is not a method or method is a forbidden method, |
176 // throw a TypeError." | 179 // throw a TypeError." |
177 if (!isValidHTTPToken(init.method)) { | 180 if (!isValidHTTPToken(init.method)) { |
178 exceptionState.throwTypeError("'" + init.method + "' is not a valid
HTTP method."); | 181 exceptionState.throwTypeError("'" + init.method + "' is not a valid
HTTP method."); |
179 return nullptr; | 182 return nullptr; |
180 } | 183 } |
(...skipping 20 matching lines...) Expand all Loading... |
201 // "28. Empty |r|'s request's header list." | 204 // "28. Empty |r|'s request's header list." |
202 r->m_request->headerList()->clearList(); | 205 r->m_request->headerList()->clearList(); |
203 // "29. If |r|'s request's mode is no CORS, run these substeps: | 206 // "29. If |r|'s request's mode is no CORS, run these substeps: |
204 if (r->request()->mode() == WebURLRequest::FetchRequestModeNoCORS) { | 207 if (r->request()->mode() == WebURLRequest::FetchRequestModeNoCORS) { |
205 // "1. If |r|'s request's method is not a simple method, throw a | 208 // "1. If |r|'s request's method is not a simple method, throw a |
206 // TypeError." | 209 // TypeError." |
207 if (!FetchUtils::isSimpleMethod(r->request()->method())) { | 210 if (!FetchUtils::isSimpleMethod(r->request()->method())) { |
208 exceptionState.throwTypeError("'" + r->request()->method() + "' is u
nsupported in no-cors mode."); | 211 exceptionState.throwTypeError("'" + r->request()->method() + "' is u
nsupported in no-cors mode."); |
209 return nullptr; | 212 return nullptr; |
210 } | 213 } |
211 // "Set |r|'s Headers object's guard to |request-no-CORS|. | 214 // "2. If |request|'s integrity metadata is not the empty string, throw |
| 215 // a TypeError." |
| 216 if (!request->integrity().isEmpty()) { |
| 217 exceptionState.throwTypeError("The integrity attribute is unsupporte
d in no-cors mode."); |
| 218 return nullptr; |
| 219 } |
| 220 // "3. Set |r|'s Headers object's guard to |request-no-CORS|. |
212 r->headers()->setGuard(Headers::RequestNoCORSGuard); | 221 r->headers()->setGuard(Headers::RequestNoCORSGuard); |
213 } | 222 } |
214 // "30. Fill |r|'s Headers object with |headers|. Rethrow any exceptions." | 223 // "30. Fill |r|'s Headers object with |headers|. Rethrow any exceptions." |
215 if (init.headers) { | 224 if (init.headers) { |
216 ASSERT(init.headersDictionary.isUndefinedOrNull()); | 225 ASSERT(init.headersDictionary.isUndefinedOrNull()); |
217 r->headers()->fillWith(init.headers.get(), exceptionState); | 226 r->headers()->fillWith(init.headers.get(), exceptionState); |
218 } else if (!init.headersDictionary.isUndefinedOrNull()) { | 227 } else if (!init.headersDictionary.isUndefinedOrNull()) { |
219 r->headers()->fillWith(init.headersDictionary, exceptionState); | 228 r->headers()->fillWith(init.headersDictionary, exceptionState); |
220 } else { | 229 } else { |
221 ASSERT(headers); | 230 ASSERT(headers); |
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
479 return "follow"; | 488 return "follow"; |
480 case WebURLRequest::FetchRedirectModeError: | 489 case WebURLRequest::FetchRedirectModeError: |
481 return "error"; | 490 return "error"; |
482 case WebURLRequest::FetchRedirectModeManual: | 491 case WebURLRequest::FetchRedirectModeManual: |
483 return "manual"; | 492 return "manual"; |
484 } | 493 } |
485 ASSERT_NOT_REACHED(); | 494 ASSERT_NOT_REACHED(); |
486 return ""; | 495 return ""; |
487 } | 496 } |
488 | 497 |
| 498 String Request::integrity() const |
| 499 { |
| 500 return m_request->integrity(); |
| 501 } |
| 502 |
489 Request* Request::clone(ExceptionState& exceptionState) | 503 Request* Request::clone(ExceptionState& exceptionState) |
490 { | 504 { |
491 if (bodyUsed()) { | 505 if (bodyUsed()) { |
492 exceptionState.throwTypeError("Request body is already used"); | 506 exceptionState.throwTypeError("Request body is already used"); |
493 return nullptr; | 507 return nullptr; |
494 } | 508 } |
495 | 509 |
496 FetchRequestData* request = m_request->clone(executionContext()); | 510 FetchRequestData* request = m_request->clone(executionContext()); |
497 Headers* headers = Headers::create(request->headerList()); | 511 Headers* headers = Headers::create(request->headerList()); |
498 headers->setGuard(m_headers->guard()); | 512 headers->setGuard(m_headers->guard()); |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
536 } | 550 } |
537 | 551 |
538 DEFINE_TRACE(Request) | 552 DEFINE_TRACE(Request) |
539 { | 553 { |
540 Body::trace(visitor); | 554 Body::trace(visitor); |
541 visitor->trace(m_request); | 555 visitor->trace(m_request); |
542 visitor->trace(m_headers); | 556 visitor->trace(m_headers); |
543 } | 557 } |
544 | 558 |
545 } // namespace blink | 559 } // namespace blink |
OLD | NEW |