OLD | NEW |
---|---|
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 Loading... | |
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 exceptionState.throwRangeError("Invalid status"); | 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" | |
161 if (status < 200 || status == 204 || status == 205 || status == 304 || 599 < status) { | |
162 exceptionState.throwRangeError(ExceptionMessages::indexOutsideRange<unsi gned>("status", status, 200, ExceptionMessages::InclusiveBound, 599, ExceptionMe ssages::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.
| |
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 } |
169 | 172 |
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
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 |
OLD | NEW |