Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(123)

Side by Side Diff: Source/modules/fetch/Request.cpp

Issue 1279163005: Initial Fetch integration for Subresource Integrity (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Add integration with FetchFormDataConsumerHandle Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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
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
yhirano 2015/08/19 10:42:36 -empty line
jww 2015/08/19 16:43:40 Done.
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
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 257 matching lines...) Expand 10 before | Expand all | Expand 10 after
472 return "follow"; 482 return "follow";
473 case WebURLRequest::FetchRedirectModeError: 483 case WebURLRequest::FetchRedirectModeError:
474 return "error"; 484 return "error";
475 case WebURLRequest::FetchRedirectModeManual: 485 case WebURLRequest::FetchRedirectModeManual:
476 return "manual"; 486 return "manual";
477 } 487 }
478 ASSERT_NOT_REACHED(); 488 ASSERT_NOT_REACHED();
479 return ""; 489 return "";
480 } 490 }
481 491
492 String Request::integrity() const
493 {
494 return m_request->integrity();
495 }
496
482 Request* Request::clone(ExceptionState& exceptionState) 497 Request* Request::clone(ExceptionState& exceptionState)
483 { 498 {
484 if (bodyUsed()) { 499 if (bodyUsed()) {
485 exceptionState.throwTypeError("Request body is already used"); 500 exceptionState.throwTypeError("Request body is already used");
486 return nullptr; 501 return nullptr;
487 } 502 }
488 503
489 FetchRequestData* request = m_request->clone(executionContext()); 504 FetchRequestData* request = m_request->clone(executionContext());
490 Headers* headers = Headers::create(request->headerList()); 505 Headers* headers = Headers::create(request->headerList());
491 headers->setGuard(m_headers->guard()); 506 headers->setGuard(m_headers->guard());
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
529 } 544 }
530 545
531 DEFINE_TRACE(Request) 546 DEFINE_TRACE(Request)
532 { 547 {
533 Body::trace(visitor); 548 Body::trace(visitor);
534 visitor->trace(m_request); 549 visitor->trace(m_request);
535 visitor->trace(m_headers); 550 visitor->trace(m_headers);
536 } 551 }
537 552
538 } // namespace blink 553 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698