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); |
} |