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

Unified Diff: Source/modules/serviceworkers/Cache.cpp

Issue 708703002: Service Worker: Cache.put() consumes request/response bodies (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Use Response bodies too, but only Request bodies if non-empty Created 6 years, 1 month 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/serviceworkers/Cache.h ('k') | Source/modules/serviceworkers/Cache.idl » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/modules/serviceworkers/Cache.cpp
diff --git a/Source/modules/serviceworkers/Cache.cpp b/Source/modules/serviceworkers/Cache.cpp
index a0c1a73250951cab419e27d42e0abdfc553dd702..206b05a2cc59f152e017af2f524c6392a7435ae2 100644
--- a/Source/modules/serviceworkers/Cache.cpp
+++ b/Source/modules/serviceworkers/Cache.cpp
@@ -219,8 +219,22 @@ ScriptPromise Cache::deleteFunction(ScriptState* scriptState, const String& requ
return deleteImpl(scriptState, request, options);
}
-ScriptPromise Cache::put(ScriptState* scriptState, Request* request, Response* response)
+ScriptPromise Cache::put(ScriptState* scriptState, Request* request, Response* response, ExceptionState& exceptionState)
{
+ if (request->hasBody() && request->bodyUsed()) {
+ exceptionState.throwTypeError("The Request's body has already been used.");
+ return ScriptPromise();
+ }
+
+ if (response->bodyUsed()) {
+ exceptionState.throwTypeError("The Response's body has already been used.");
+ return ScriptPromise();
+ }
+
+ if (request->hasBody())
+ request->setBodyUsed();
+ response->setBodyUsed();
bkelly 2014/11/07 20:35:19 While it will be a somewhat rare case, it is possi
+
return putImpl(scriptState, request, response);
}
@@ -229,6 +243,13 @@ ScriptPromise Cache::put(ScriptState* scriptState, const String& requestString,
Request* request = Request::create(scriptState->executionContext(), requestString, exceptionState);
if (exceptionState.hadException())
return ScriptPromise();
+
+ if (response->bodyUsed()) {
+ exceptionState.throwTypeError("The Response's body has already been used.");
+ return ScriptPromise();
+ }
+ response->setBodyUsed();
bkelly 2014/11/07 20:35:19 Likewise, check hasBody() here as well.
+
return putImpl(scriptState, request, response);
}
« no previous file with comments | « Source/modules/serviceworkers/Cache.h ('k') | Source/modules/serviceworkers/Cache.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698