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

Side by Side Diff: third_party/WebKit/Source/modules/fetch/Response.cpp

Issue 2840193002: fetch: Align RequestInit's |headers| with the spec. (Closed)
Patch Set: Add HeadersInit typedef Created 3 years, 7 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
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 "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/V8BindingForCore.h" 13 #include "bindings/core/v8/V8BindingForCore.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/ByteStringSequenceSequenceOrByteStringByteStringRe cordOrHeaders.h"
19 #include "core/dom/DOMArrayBuffer.h" 18 #include "core/dom/DOMArrayBuffer.h"
20 #include "core/dom/DOMArrayBufferView.h" 19 #include "core/dom/DOMArrayBufferView.h"
21 #include "core/dom/ExecutionContext.h" 20 #include "core/dom/ExecutionContext.h"
22 #include "core/dom/URLSearchParams.h" 21 #include "core/dom/URLSearchParams.h"
23 #include "core/fileapi/Blob.h" 22 #include "core/fileapi/Blob.h"
24 #include "core/frame/UseCounter.h" 23 #include "core/frame/UseCounter.h"
25 #include "core/html/FormData.h" 24 #include "core/html/FormData.h"
26 #include "core/streams/ReadableStreamOperations.h" 25 #include "core/streams/ReadableStreamOperations.h"
27 #include "modules/fetch/BlobBytesConsumer.h" 26 #include "modules/fetch/BlobBytesConsumer.h"
28 #include "modules/fetch/BodyStreamBuffer.h" 27 #include "modules/fetch/BodyStreamBuffer.h"
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
222 221
223 // "5. Set |r|'s response's status message to |init|'s statusText member." 222 // "5. Set |r|'s response's status message to |init|'s statusText member."
224 r->response_->SetStatusMessage(AtomicString(init.statusText())); 223 r->response_->SetStatusMessage(AtomicString(init.statusText()));
225 224
226 // "6. If |init|'s headers member is present, run these substeps:" 225 // "6. If |init|'s headers member is present, run these substeps:"
227 if (init.hasHeaders()) { 226 if (init.hasHeaders()) {
228 // "1. Empty |r|'s response's header list." 227 // "1. Empty |r|'s response's header list."
229 r->response_->HeaderList()->ClearList(); 228 r->response_->HeaderList()->ClearList();
230 // "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
231 // any exceptions." 230 // any exceptions."
232 if (init.headers().isByteStringSequenceSequence()) { 231 r->headers_->FillWith(init.headers(), exception_state);
233 r->headers_->FillWith(init.headers().getAsByteStringSequenceSequence(),
234 exception_state);
235 } else if (init.headers().isByteStringByteStringRecord()) {
236 r->headers_->FillWith(init.headers().getAsByteStringByteStringRecord(),
237 exception_state);
238 } else if (init.headers().isHeaders()) {
239 r->headers_->FillWith(init.headers().getAsHeaders(), exception_state);
240 }
241 if (exception_state.HadException()) 232 if (exception_state.HadException())
242 return nullptr; 233 return nullptr;
243 } 234 }
244 // "7. If body is given, run these substeps:" 235 // "7. If body is given, run these substeps:"
245 if (body) { 236 if (body) {
246 // "1. If |init|'s status member is a null body status, throw a 237 // "1. If |init|'s status member is a null body status, throw a
247 // TypeError." 238 // TypeError."
248 // "2. Let |stream| and |Content-Type| be the result of extracting 239 // "2. Let |stream| and |Content-Type| be the result of extracting
249 // body." 240 // body."
250 // "3. Set |r|'s response's body to |stream|." 241 // "3. Set |r|'s response's body to |stream|."
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after
463 .Set(response.As<v8::Object>(), body_buffer); 454 .Set(response.As<v8::Object>(), body_buffer);
464 } 455 }
465 456
466 DEFINE_TRACE(Response) { 457 DEFINE_TRACE(Response) {
467 Body::Trace(visitor); 458 Body::Trace(visitor);
468 visitor->Trace(response_); 459 visitor->Trace(response_);
469 visitor->Trace(headers_); 460 visitor->Trace(headers_);
470 } 461 }
471 462
472 } // namespace blink 463 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698