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

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

Issue 882383002: [Fetch] Request with GET/HEAD method cannot have body (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 11 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/serviceworker/resources/cache-put-worker.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 9e4ace193ce20ce3e8e98febb5a0c4aff5288b24..b6ae9409ceda7c69d3b77896e3aef837578f6a94 100644
--- a/Source/modules/fetch/Request.cpp
+++ b/Source/modules/fetch/Request.cpp
@@ -179,13 +179,18 @@ Request* Request::createRequestWithRequestOrString(ExecutionContext* context, Re
// "21. If |init|'s body member is present, run these substeps:"
if (init.bodyBlobHandle) {
- // "1. Let |stream| and |Content-Type| be the result of extracting
- // |init|'s body member."
- // "2. Set |r|'s request's body to |stream|."
- // "3.If |Content-Type| is non-null and |r|'s request's header list
+ // "1. If request's method is `GET` or `HEAD`, throw a TypeError."
+ // "2. Let |stream| and |Content-Type| be the result of extracting
+ // |init|'s body member."
+ // "3. Set |r|'s request's body to |stream|."
+ // "4. If |Content-Type| is non-null and |r|'s request's header list
// contains no header named `Content-Type`, append
- // `Content-Type`/|Content-Type| to |r|'s Headers object. Rethrow any
- // exception."
+ // `Content-Type`/|Content-Type| to |r|'s Headers object. Rethrow any
+ // exception."
+ if (request->method() == "GET" || request->method() == "HEAD") {
+ exceptionState.throwTypeError("Request with GET/HEAD method cannot have body.");
+ return 0;
+ }
r->setBodyBlobHandle(init.bodyBlobHandle);
if (!init.bodyBlobHandle->type().isEmpty() && !r->headers()->has("Content-Type", exceptionState)) {
r->headers()->append("Content-Type", init.bodyBlobHandle->type(), exceptionState);
« no previous file with comments | « LayoutTests/http/tests/serviceworker/resources/cache-put-worker.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698