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

Unified Diff: Source/modules/fetch/Request.cpp

Issue 1187653003: [Fetch] Check / Set .bodyUsed in Request construction if the src body is null. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 6 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 | « LayoutTests/http/tests/fetch/script-tests/request.js ('k') | no next file » | 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 8e26455835b151b4c93e53dd1096be81aea80c8c..82e6f5ad415045af0344498b0e441dcafa50d56b 100644
--- a/Source/modules/fetch/Request.cpp
+++ b/Source/modules/fetch/Request.cpp
@@ -49,6 +49,15 @@ Request* Request::createRequestWithRequestOrString(ScriptState* scriptState, Req
// "1. Let |temporaryBody| be null."
RefPtr<BlobDataHandle> temporaryBody;
+ if (inputRequest) {
+ // We check bodyUsed even when the body is null in spite of the
+ // spec. See https://github.com/whatwg/fetch/issues/61 for details.
+ if (inputRequest->bodyUsed()) {
tyoshino (SeeGerritForStatus) 2015/06/18 06:34:34 are these if-s separated intentionally?
yhirano 2015/06/18 06:44:24 Yes.
+ exceptionState.throwTypeError("Cannot construct a Request with a Request object that has already been used.");
+ return nullptr;
+ }
+ }
+
// "2. If |input| is a Request object and |input|'s body is non-null, run
// these substeps:"
if (inputRequest && inputRequest->hasBody()) {
@@ -243,7 +252,9 @@ Request* Request::createRequestWithRequestOrString(ScriptState* scriptState, Req
// "31. If |input| is a Request object and |input|'s body is non-null, run
// these substeps:"
- if (inputRequest && inputRequest->hasBody()) {
+ // We set bodyUsed even when the body is null in spite of the
+ // spec. See https://github.com/whatwg/fetch/issues/61 for details.
+ if (inputRequest) {
// "1. Set |input|'s body to null."
inputRequest->setBodyBlobHandle(nullptr);
// "2. Set |input|'s used flag."
« no previous file with comments | « LayoutTests/http/tests/fetch/script-tests/request.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698