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

Side by Side Diff: third_party/WebKit/Source/modules/fetch/RequestInit.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/RequestInit.h" 5 #include "modules/fetch/RequestInit.h"
6 6
7 #include "bindings/core/v8/Dictionary.h" 7 #include "bindings/core/v8/Dictionary.h"
8 #include "bindings/core/v8/V8ArrayBuffer.h" 8 #include "bindings/core/v8/V8ArrayBuffer.h"
9 #include "bindings/core/v8/V8ArrayBufferView.h" 9 #include "bindings/core/v8/V8ArrayBufferView.h"
10 #include "bindings/core/v8/V8BindingForCore.h" 10 #include "bindings/core/v8/V8BindingForCore.h"
11 #include "bindings/core/v8/V8Blob.h" 11 #include "bindings/core/v8/V8Blob.h"
12 #include "bindings/core/v8/V8FormData.h" 12 #include "bindings/core/v8/V8FormData.h"
13 #include "bindings/core/v8/V8URLSearchParams.h" 13 #include "bindings/core/v8/V8URLSearchParams.h"
14 #include "bindings/modules/v8/ByteStringSequenceSequenceOrByteStringByteStringRe cordOrHeaders.h"
15 #include "bindings/modules/v8/V8PasswordCredential.h" 14 #include "bindings/modules/v8/V8PasswordCredential.h"
16 #include "core/dom/URLSearchParams.h" 15 #include "core/dom/URLSearchParams.h"
17 #include "core/fileapi/Blob.h" 16 #include "core/fileapi/Blob.h"
18 #include "core/html/FormData.h" 17 #include "core/html/FormData.h"
19 #include "modules/fetch/BlobBytesConsumer.h" 18 #include "modules/fetch/BlobBytesConsumer.h"
20 #include "modules/fetch/FormDataBytesConsumer.h" 19 #include "modules/fetch/FormDataBytesConsumer.h"
21 #include "modules/fetch/Headers.h" 20 #include "modules/fetch/Headers.h"
22 #include "platform/RuntimeEnabledFeatures.h" 21 #include "platform/RuntimeEnabledFeatures.h"
23 #include "platform/blob/BlobData.h" 22 #include "platform/blob/BlobData.h"
24 #include "platform/network/EncodedFormData.h" 23 #include "platform/network/EncodedFormData.h"
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 } else { 99 } else {
101 exception_state.ThrowTypeError("Invalid referrer policy"); 100 exception_state.ThrowTypeError("Invalid referrer policy");
102 return; 101 return;
103 } 102 }
104 } 103 }
105 } 104 }
106 105
107 v8::Isolate* isolate = ToIsolate(context); 106 v8::Isolate* isolate = ToIsolate(context);
108 107
109 if (is_header_set) { 108 if (is_header_set) {
110 ByteStringSequenceSequenceOrByteStringByteStringRecordOrHeaders
111 headers_init;
112 V8ByteStringSequenceSequenceOrByteStringByteStringRecordOrHeaders::toImpl( 109 V8ByteStringSequenceSequenceOrByteStringByteStringRecordOrHeaders::toImpl(
113 isolate, v8_headers, headers_init, 110 isolate, v8_headers, headers, UnionTypeConversionMode::kNotNullable,
114 UnionTypeConversionMode::kNotNullable, exception_state); 111 exception_state);
115 if (exception_state.HadException())
116 return;
117 headers = Headers::Create(headers_init, exception_state);
118 if (exception_state.HadException()) 112 if (exception_state.HadException())
119 return; 113 return;
120 } 114 }
121 115
122 if (is_credential_set) { 116 if (is_credential_set) {
123 if (V8PasswordCredential::hasInstance(v8_credential, isolate)) { 117 if (V8PasswordCredential::hasInstance(v8_credential, isolate)) {
124 // TODO(mkwst): According to the spec, we'd serialize this once we touch 118 // TODO(mkwst): According to the spec, we'd serialize this once we touch
125 // the network. We're serializing it here, ahead of time, because lifetime 119 // the network. We're serializing it here, ahead of time, because lifetime
126 // issues around ResourceRequest make it pretty difficult to pass a 120 // issues around ResourceRequest make it pretty difficult to pass a
127 // PasswordCredential around at the platform level, and the hop between 121 // PasswordCredential around at the platform level, and the hop between
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
169 AtomicString("application/x-www-form-urlencoded;charset=UTF-8"); 163 AtomicString("application/x-www-form-urlencoded;charset=UTF-8");
170 body = new FormDataBytesConsumer(context, form_data.Release()); 164 body = new FormDataBytesConsumer(context, form_data.Release());
171 } else if (v8_body->IsString()) { 165 } else if (v8_body->IsString()) {
172 content_type = "text/plain;charset=UTF-8"; 166 content_type = "text/plain;charset=UTF-8";
173 body = new FormDataBytesConsumer( 167 body = new FormDataBytesConsumer(
174 ToUSVString(isolate, v8_body, exception_state)); 168 ToUSVString(isolate, v8_body, exception_state));
175 } 169 }
176 } 170 }
177 171
178 } // namespace blink 172 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698