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

Side by Side 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, 4 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 unified diff | Download patch
« no previous file with comments | « LayoutTests/http/tests/fetch/script-tests/response.js ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "config.h" 5 #include "config.h"
6 #include "modules/fetch/Response.h" 6 #include "modules/fetch/Response.h"
7 7
8 #include "bindings/core/v8/Dictionary.h" 8 #include "bindings/core/v8/Dictionary.h"
9 #include "bindings/core/v8/ExceptionState.h" 9 #include "bindings/core/v8/ExceptionState.h"
10 #include "core/dom/DOMArrayBuffer.h" 10 #include "core/dom/DOMArrayBuffer.h"
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 const long long length = blobData->length(); 146 const long long length = blobData->length();
147 Blob* blob = Blob::create(BlobDataHandle::create(blobData.release(), len gth)); 147 Blob* blob = Blob::create(BlobDataHandle::create(blobData.release(), len gth));
148 return create(context, blob, ResponseInit(responseInit, exceptionState), exceptionState); 148 return create(context, blob, ResponseInit(responseInit, exceptionState), exceptionState);
149 } 149 }
150 ASSERT_NOT_REACHED(); 150 ASSERT_NOT_REACHED();
151 return nullptr; 151 return nullptr;
152 } 152 }
153 153
154 Response* Response::create(ExecutionContext* context, Blob* body, const Response Init& responseInit, ExceptionState& exceptionState) 154 Response* Response::create(ExecutionContext* context, Blob* body, const Response Init& responseInit, ExceptionState& exceptionState)
155 { 155 {
156 // "1. If |init|'s status member is not in the range 200 to 599, throw a 156 unsigned short status = responseInit.status;
157 // RangeError." 157
158 if (responseInit.status < 200 || 599 < responseInit.status) { 158 // "1. If init's status member is either not in the range 200 to 599, inclus ive,
159 // or is a null body status, throw a RangeError. A null body status is 101, 204, 205, or 304,
160 // spec link, See https://fetch.spec.whatwg.org/#null-body-status for detail s"
hiroshige 2015/07/29 11:49:11 According to the latest spec, - null body status c
shiva.jm 2015/07/30 09:10:42 Done.
161 if (status < 200 || status == 204 || status == 205 || status == 304 || 599 < status) {
hiroshige 2015/07/29 11:49:11 Please define isNullBodyStatus() in the anonymous
shiva.jm 2015/07/30 09:10:42 Done.
159 exceptionState.throwRangeError("Invalid status"); 162 exceptionState.throwRangeError("Invalid status");
160 return 0; 163 return 0;
161 } 164 }
162 165
163 // "2. If |init|'s statusText member does not match the Reason-Phrase 166 // "2. If |init|'s statusText member does not match the Reason-Phrase
164 // token production, throw a TypeError." 167 // token production, throw a TypeError."
165 if (!isValidReasonPhrase(responseInit.statusText)) { 168 if (!isValidReasonPhrase(responseInit.statusText)) {
166 exceptionState.throwTypeError("Invalid statusText"); 169 exceptionState.throwTypeError("Invalid statusText");
167 return 0; 170 return 0;
168 } 171 }
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after
434 } 437 }
435 438
436 DEFINE_TRACE(Response) 439 DEFINE_TRACE(Response)
437 { 440 {
438 Body::trace(visitor); 441 Body::trace(visitor);
439 visitor->trace(m_response); 442 visitor->trace(m_response);
440 visitor->trace(m_headers); 443 visitor->trace(m_headers);
441 } 444 }
442 445
443 } // namespace blink 446 } // namespace blink
OLDNEW
« 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