Chromium Code Reviews| Index: third_party/WebKit/Source/modules/fetch/RequestInit.cpp |
| diff --git a/third_party/WebKit/Source/modules/fetch/RequestInit.cpp b/third_party/WebKit/Source/modules/fetch/RequestInit.cpp |
| index 54a76a215bdb1497bd74102830eef4e701a0dc90..badb2efb3df22b65c3da6e06e25ef0948ea47159 100644 |
| --- a/third_party/WebKit/Source/modules/fetch/RequestInit.cpp |
| +++ b/third_party/WebKit/Source/modules/fetch/RequestInit.cpp |
| @@ -11,6 +11,7 @@ |
| #include "bindings/core/v8/V8Blob.h" |
| #include "bindings/core/v8/V8FormData.h" |
| #include "bindings/core/v8/V8URLSearchParams.h" |
| +#include "bindings/modules/v8/ByteStringSequenceSequenceOrDictionaryOrHeaders.h" |
| #include "bindings/modules/v8/V8PasswordCredential.h" |
| #include "core/dom/URLSearchParams.h" |
| #include "core/fileapi/Blob.h" |
| @@ -30,18 +31,12 @@ RequestInit::RequestInit(ExecutionContext* context, |
| ExceptionState& exceptionState) |
| : areAnyMembersSet(false) { |
| areAnyMembersSet |= DictionaryHelper::get(options, "method", method); |
| - areAnyMembersSet |= DictionaryHelper::get(options, "headers", headers); |
| - if (!headers) { |
| - Vector<Vector<String>> headersVector; |
| - if (DictionaryHelper::get(options, "headers", headersVector, |
| - exceptionState)) { |
| - headers = Headers::create(headersVector, exceptionState); |
| - areAnyMembersSet = true; |
| - } else { |
| - areAnyMembersSet |= |
| - DictionaryHelper::get(options, "headers", headersDictionary); |
| - } |
| - } |
| + |
| + v8::Local<v8::Value> v8Headers; |
| + bool isHeadersSet = DictionaryHelper::get(options, "headers", v8Headers) && |
| + !v8Headers.IsEmpty() && !v8Headers->IsUndefined(); |
|
yhirano
2017/02/14 03:28:50
The same applies for null, I believe.
|
| + areAnyMembersSet |= isHeadersSet; |
| + |
| areAnyMembersSet |= DictionaryHelper::get(options, "mode", mode); |
| areAnyMembersSet |= DictionaryHelper::get(options, "redirect", redirect); |
| AtomicString referrerString; |
| @@ -99,6 +94,15 @@ RequestInit::RequestInit(ExecutionContext* context, |
| } |
| v8::Isolate* isolate = toIsolate(context); |
| + |
| + if (isHeadersSet) { |
| + ByteStringSequenceSequenceOrDictionaryOrHeaders headersInit; |
| + V8ByteStringSequenceSequenceOrDictionaryOrHeaders::toImpl( |
| + isolate, v8Headers, headersInit, UnionTypeConversionMode::NotNullable, |
| + exceptionState); |
| + headers = Headers::create(headersInit, exceptionState); |
| + } |
| + |
| if (isCredentialSet) { |
| if (V8PasswordCredential::hasInstance(v8Credential, isolate)) { |
| // TODO(mkwst): According to the spec, we'd serialize this once we touch |