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 "modules/fetch/Response.h" | 5 #include "modules/fetch/Response.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
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 "bindings/core/v8/ScriptState.h" | 10 #include "bindings/core/v8/ScriptState.h" |
11 #include "bindings/core/v8/V8ArrayBuffer.h" | 11 #include "bindings/core/v8/V8ArrayBuffer.h" |
12 #include "bindings/core/v8/V8ArrayBufferView.h" | 12 #include "bindings/core/v8/V8ArrayBufferView.h" |
13 #include "bindings/core/v8/V8Binding.h" | 13 #include "bindings/core/v8/V8Binding.h" |
14 #include "bindings/core/v8/V8Blob.h" | 14 #include "bindings/core/v8/V8Blob.h" |
15 #include "bindings/core/v8/V8FormData.h" | 15 #include "bindings/core/v8/V8FormData.h" |
16 #include "bindings/core/v8/V8PrivateProperty.h" | 16 #include "bindings/core/v8/V8PrivateProperty.h" |
17 #include "bindings/core/v8/V8URLSearchParams.h" | 17 #include "bindings/core/v8/V8URLSearchParams.h" |
18 #include "bindings/modules/v8/ByteStringSequenceSequenceOrDictionaryOrHeaders.h" | 18 #include "bindings/modules/v8/ByteStringSequenceSequenceOrByteStringByteStringRe
cordOrHeaders.h" |
19 #include "core/dom/DOMArrayBuffer.h" | 19 #include "core/dom/DOMArrayBuffer.h" |
20 #include "core/dom/DOMArrayBufferView.h" | 20 #include "core/dom/DOMArrayBufferView.h" |
21 #include "core/dom/URLSearchParams.h" | 21 #include "core/dom/URLSearchParams.h" |
22 #include "core/fileapi/Blob.h" | 22 #include "core/fileapi/Blob.h" |
23 #include "core/frame/UseCounter.h" | 23 #include "core/frame/UseCounter.h" |
24 #include "core/html/FormData.h" | 24 #include "core/html/FormData.h" |
25 #include "core/streams/ReadableStreamOperations.h" | 25 #include "core/streams/ReadableStreamOperations.h" |
26 #include "modules/fetch/BlobBytesConsumer.h" | 26 #include "modules/fetch/BlobBytesConsumer.h" |
27 #include "modules/fetch/BodyStreamBuffer.h" | 27 #include "modules/fetch/BodyStreamBuffer.h" |
28 #include "modules/fetch/FormDataBytesConsumer.h" | 28 #include "modules/fetch/FormDataBytesConsumer.h" |
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
224 | 224 |
225 // "6. If |init|'s headers member is present, run these substeps:" | 225 // "6. If |init|'s headers member is present, run these substeps:" |
226 if (init.hasHeaders()) { | 226 if (init.hasHeaders()) { |
227 // "1. Empty |r|'s response's header list." | 227 // "1. Empty |r|'s response's header list." |
228 r->response_->HeaderList()->ClearList(); | 228 r->response_->HeaderList()->ClearList(); |
229 // "2. Fill |r|'s Headers object with |init|'s headers member. Rethrow | 229 // "2. Fill |r|'s Headers object with |init|'s headers member. Rethrow |
230 // any exceptions." | 230 // any exceptions." |
231 if (init.headers().isByteStringSequenceSequence()) { | 231 if (init.headers().isByteStringSequenceSequence()) { |
232 r->headers_->FillWith(init.headers().getAsByteStringSequenceSequence(), | 232 r->headers_->FillWith(init.headers().getAsByteStringSequenceSequence(), |
233 exception_state); | 233 exception_state); |
234 } else if (init.headers().isDictionary()) { | 234 } else if (init.headers().isByteStringByteStringRecord()) { |
235 r->headers_->FillWith(init.headers().getAsDictionary(), exception_state); | 235 r->headers_->FillWith(init.headers().getAsByteStringByteStringRecord(), |
| 236 exception_state); |
236 } else if (init.headers().isHeaders()) { | 237 } else if (init.headers().isHeaders()) { |
237 r->headers_->FillWith(init.headers().getAsHeaders(), exception_state); | 238 r->headers_->FillWith(init.headers().getAsHeaders(), exception_state); |
238 } | 239 } |
239 if (exception_state.HadException()) | 240 if (exception_state.HadException()) |
240 return nullptr; | 241 return nullptr; |
241 } | 242 } |
242 // "7. If body is given, run these substeps:" | 243 // "7. If body is given, run these substeps:" |
243 if (body) { | 244 if (body) { |
244 // "1. If |init|'s status member is a null body status, throw a | 245 // "1. If |init|'s status member is a null body status, throw a |
245 // TypeError." | 246 // TypeError." |
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
461 .Set(response.As<v8::Object>(), body_buffer); | 462 .Set(response.As<v8::Object>(), body_buffer); |
462 } | 463 } |
463 | 464 |
464 DEFINE_TRACE(Response) { | 465 DEFINE_TRACE(Response) { |
465 Body::Trace(visitor); | 466 Body::Trace(visitor); |
466 visitor->Trace(response_); | 467 visitor->Trace(response_); |
467 visitor->Trace(headers_); | 468 visitor->Trace(headers_); |
468 } | 469 } |
469 | 470 |
470 } // namespace blink | 471 } // namespace blink |
OLD | NEW |