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 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." |
| 165 if (!init.integrity.isNull()) |
| 166 request->setIntegrity(init.integrity); |
164 | 167 |
165 // "24. If |init|'s method member is present, let |method| be it and run | 168 // "24. If |init|'s method member is present, let |method| be it and run |
166 // these substeps:" | 169 // these substeps:" |
167 if (!init.method.isNull()) { | 170 if (!init.method.isNull()) { |
168 // "1. If |method| is not a method or method is a forbidden method, | 171 // "1. If |method| is not a method or method is a forbidden method, |
169 // throw a TypeError." | 172 // throw a TypeError." |
170 if (!isValidHTTPToken(init.method)) { | 173 if (!isValidHTTPToken(init.method)) { |
171 exceptionState.throwTypeError("'" + init.method + "' is not a valid
HTTP method."); | 174 exceptionState.throwTypeError("'" + init.method + "' is not a valid
HTTP method."); |
172 return nullptr; | 175 return nullptr; |
173 } | 176 } |
(...skipping 20 matching lines...) Expand all Loading... |
194 // "28. Empty |r|'s request's header list." | 197 // "28. Empty |r|'s request's header list." |
195 r->m_request->headerList()->clearList(); | 198 r->m_request->headerList()->clearList(); |
196 // "29. If |r|'s request's mode is no CORS, run these substeps: | 199 // "29. If |r|'s request's mode is no CORS, run these substeps: |
197 if (r->request()->mode() == WebURLRequest::FetchRequestModeNoCORS) { | 200 if (r->request()->mode() == WebURLRequest::FetchRequestModeNoCORS) { |
198 // "1. If |r|'s request's method is not a simple method, throw a | 201 // "1. If |r|'s request's method is not a simple method, throw a |
199 // TypeError." | 202 // TypeError." |
200 if (!FetchUtils::isSimpleMethod(r->request()->method())) { | 203 if (!FetchUtils::isSimpleMethod(r->request()->method())) { |
201 exceptionState.throwTypeError("'" + r->request()->method() + "' is u
nsupported in no-cors mode."); | 204 exceptionState.throwTypeError("'" + r->request()->method() + "' is u
nsupported in no-cors mode."); |
202 return nullptr; | 205 return nullptr; |
203 } | 206 } |
204 // "Set |r|'s Headers object's guard to |request-no-CORS|. | 207 // "2. If |request|'s integrity metadata is not the empty string, throw |
| 208 // a TypeError." |
| 209 if (!request->integrity().isEmpty()) { |
| 210 exceptionState.throwTypeError("The integrity attribute is unsupporte
d in no-cors mode."); |
| 211 return nullptr; |
| 212 } |
| 213 // "3. Set |r|'s Headers object's guard to |request-no-CORS|. |
205 r->headers()->setGuard(Headers::RequestNoCORSGuard); | 214 r->headers()->setGuard(Headers::RequestNoCORSGuard); |
206 } | 215 } |
207 // "30. Fill |r|'s Headers object with |headers|. Rethrow any exceptions." | 216 // "30. Fill |r|'s Headers object with |headers|. Rethrow any exceptions." |
208 if (init.headers) { | 217 if (init.headers) { |
209 ASSERT(init.headersDictionary.isUndefinedOrNull()); | 218 ASSERT(init.headersDictionary.isUndefinedOrNull()); |
210 r->headers()->fillWith(init.headers.get(), exceptionState); | 219 r->headers()->fillWith(init.headers.get(), exceptionState); |
211 } else if (!init.headersDictionary.isUndefinedOrNull()) { | 220 } else if (!init.headersDictionary.isUndefinedOrNull()) { |
212 r->headers()->fillWith(init.headersDictionary, exceptionState); | 221 r->headers()->fillWith(init.headersDictionary, exceptionState); |
213 } else { | 222 } else { |
214 ASSERT(headers); | 223 ASSERT(headers); |
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
472 return "follow"; | 481 return "follow"; |
473 case WebURLRequest::FetchRedirectModeError: | 482 case WebURLRequest::FetchRedirectModeError: |
474 return "error"; | 483 return "error"; |
475 case WebURLRequest::FetchRedirectModeManual: | 484 case WebURLRequest::FetchRedirectModeManual: |
476 return "manual"; | 485 return "manual"; |
477 } | 486 } |
478 ASSERT_NOT_REACHED(); | 487 ASSERT_NOT_REACHED(); |
479 return ""; | 488 return ""; |
480 } | 489 } |
481 | 490 |
| 491 String Request::integrity() const |
| 492 { |
| 493 return m_request->integrity(); |
| 494 } |
| 495 |
482 Request* Request::clone(ExceptionState& exceptionState) | 496 Request* Request::clone(ExceptionState& exceptionState) |
483 { | 497 { |
484 if (bodyUsed()) { | 498 if (bodyUsed()) { |
485 exceptionState.throwTypeError("Request body is already used"); | 499 exceptionState.throwTypeError("Request body is already used"); |
486 return nullptr; | 500 return nullptr; |
487 } | 501 } |
488 | 502 |
489 FetchRequestData* request = m_request->clone(executionContext()); | 503 FetchRequestData* request = m_request->clone(executionContext()); |
490 Headers* headers = Headers::create(request->headerList()); | 504 Headers* headers = Headers::create(request->headerList()); |
491 headers->setGuard(m_headers->guard()); | 505 headers->setGuard(m_headers->guard()); |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
529 } | 543 } |
530 | 544 |
531 DEFINE_TRACE(Request) | 545 DEFINE_TRACE(Request) |
532 { | 546 { |
533 Body::trace(visitor); | 547 Body::trace(visitor); |
534 visitor->trace(m_request); | 548 visitor->trace(m_request); |
535 visitor->trace(m_headers); | 549 visitor->trace(m_headers); |
536 } | 550 } |
537 | 551 |
538 } // namespace blink | 552 } // namespace blink |
OLD | NEW |