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

Unified 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: Fix test expectations 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/modules/fetch/Request.h ('k') | Source/modules/fetch/Request.idl » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/modules/fetch/Request.cpp
diff --git a/Source/modules/fetch/Request.cpp b/Source/modules/fetch/Request.cpp
index 7d4223c09ba2756cbfd23e77ac3d5f9bae849501..830023c354a4805da7e9da4964140a6ab7a96127 100644
--- a/Source/modules/fetch/Request.cpp
+++ b/Source/modules/fetch/Request.cpp
@@ -42,6 +42,7 @@ FetchRequestData* createCopyOfFetchRequestDataForFetch(ScriptState* scriptState,
request->setMode(original->mode());
request->setCredentials(original->credentials());
request->setRedirect(original->redirect());
+ request->setIntegrity(original->integrity());
// FIXME: Set cache mode.
// TODO(yhirano): Set redirect mode.
return request;
@@ -166,8 +167,10 @@ Request* Request::createRequestWithRequestOrString(ScriptState* scriptState, Req
request->setRedirect(WebURLRequest::FetchRedirectModeManual);
}
- // TODO(jww): "23. If |init|'s integrity member is present, set |request|'s
+ // "If |init|'s integrity member is present, set |request|'s
// integrity metadata to it."
+ if (!init.integrity.isNull())
+ request->setIntegrity(init.integrity);
// "24. If |init|'s method member is present, let |method| be it and run
// these substeps:"
@@ -208,7 +211,13 @@ Request* Request::createRequestWithRequestOrString(ScriptState* scriptState, Req
exceptionState.throwTypeError("'" + r->request()->method() + "' is unsupported in no-cors mode.");
return nullptr;
}
- // "Set |r|'s Headers object's guard to |request-no-CORS|.
+ // "2. If |request|'s integrity metadata is not the empty string, throw
+ // a TypeError."
+ if (!request->integrity().isEmpty()) {
+ exceptionState.throwTypeError("The integrity attribute is unsupported in no-cors mode.");
+ return nullptr;
+ }
+ // "3. Set |r|'s Headers object's guard to |request-no-CORS|.
r->headers()->setGuard(Headers::RequestNoCORSGuard);
}
// "30. Fill |r|'s Headers object with |headers|. Rethrow any exceptions."
@@ -486,6 +495,11 @@ String Request::redirect() const
return "";
}
+String Request::integrity() const
+{
+ return m_request->integrity();
+}
+
Request* Request::clone(ExceptionState& exceptionState)
{
if (bodyUsed()) {
« no previous file with comments | « Source/modules/fetch/Request.h ('k') | Source/modules/fetch/Request.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698