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

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

Issue 1258933002: Make the Response constructor throw when status is a null body status and body is non-null (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 5 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/response.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/Response.cpp
diff --git a/Source/modules/fetch/Response.cpp b/Source/modules/fetch/Response.cpp
index 29c7c0de34933f6a711117f2692aea6a6a8abcba..0307c8bbe8492645ba0eb8e7f5a308c14e1438bf 100644
--- a/Source/modules/fetch/Response.cpp
+++ b/Source/modules/fetch/Response.cpp
@@ -153,10 +153,13 @@ Response* Response::create(ExecutionContext* context, const BodyInit& body, cons
Response* Response::create(ExecutionContext* context, Blob* body, const ResponseInit& responseInit, ExceptionState& exceptionState)
{
- // "1. If |init|'s status member is not in the range 200 to 599, throw a
- // RangeError."
- if (responseInit.status < 200 || 599 < responseInit.status) {
- exceptionState.throwRangeError("Invalid status");
+ unsigned short status = responseInit.status;
+
+ // "1. If init's status member is either not in the range 200 to 599, inclusive,
+ // or is a null body status, throw a RangeError. A null body status is 101, 204, 205, or 304,
+ // spec link, See https://fetch.spec.whatwg.org/#null-body-status for details"
+ if (status < 200 || status == 204 || status == 205 || status == 304 || 599 < status) {
+ exceptionState.throwRangeError(ExceptionMessages::indexOutsideRange<unsigned>("status", status, 200, ExceptionMessages::InclusiveBound, 599, ExceptionMessages::InclusiveBound));
philipj_slow 2015/07/29 09:15:46 The exception message doesn't make sense with the
shiva.jm 2015/07/29 11:22:24 Done.
shiva.jm 2015/07/29 11:22:25 Done.
return 0;
}
« no previous file with comments | « LayoutTests/http/tests/fetch/script-tests/response.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698