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/RequestInit.h" | 6 #include "modules/fetch/RequestInit.h" |
7 | 7 |
8 #include "bindings/core/v8/Dictionary.h" | 8 #include "bindings/core/v8/Dictionary.h" |
9 #include "bindings/core/v8/V8ArrayBuffer.h" | 9 #include "bindings/core/v8/V8ArrayBuffer.h" |
10 #include "bindings/core/v8/V8ArrayBufferView.h" | 10 #include "bindings/core/v8/V8ArrayBufferView.h" |
(...skipping 16 matching lines...) Expand all Loading... |
27 if (!headers) { | 27 if (!headers) { |
28 Vector<Vector<String>> headersVector; | 28 Vector<Vector<String>> headersVector; |
29 if (DictionaryHelper::get(options, "headers", headersVector, exceptionSt
ate)) | 29 if (DictionaryHelper::get(options, "headers", headersVector, exceptionSt
ate)) |
30 headers = Headers::create(headersVector, exceptionState); | 30 headers = Headers::create(headersVector, exceptionState); |
31 else | 31 else |
32 DictionaryHelper::get(options, "headers", headersDictionary); | 32 DictionaryHelper::get(options, "headers", headersDictionary); |
33 } | 33 } |
34 DictionaryHelper::get(options, "mode", mode); | 34 DictionaryHelper::get(options, "mode", mode); |
35 DictionaryHelper::get(options, "credentials", credentials); | 35 DictionaryHelper::get(options, "credentials", credentials); |
36 DictionaryHelper::get(options, "redirect", redirect); | 36 DictionaryHelper::get(options, "redirect", redirect); |
| 37 DictionaryHelper::get(options, "integrity", integrity); |
37 | 38 |
38 v8::Local<v8::Value> v8Body; | 39 v8::Local<v8::Value> v8Body; |
39 if (!DictionaryHelper::get(options, "body", v8Body) || v8Body->IsUndefined()
|| v8Body->IsNull()) | 40 if (!DictionaryHelper::get(options, "body", v8Body) || v8Body->IsUndefined()
|| v8Body->IsNull()) |
40 return; | 41 return; |
41 v8::Isolate* isolate = toIsolate(context); | 42 v8::Isolate* isolate = toIsolate(context); |
42 if (v8Body->IsArrayBuffer()) { | 43 if (v8Body->IsArrayBuffer()) { |
43 body = FetchFormDataConsumerHandle::create(V8ArrayBuffer::toImpl(v8::Loc
al<v8::Object>::Cast(v8Body))); | 44 body = FetchFormDataConsumerHandle::create(V8ArrayBuffer::toImpl(v8::Loc
al<v8::Object>::Cast(v8Body))); |
44 } else if (v8Body->IsArrayBufferView()) { | 45 } else if (v8Body->IsArrayBufferView()) { |
45 body = FetchFormDataConsumerHandle::create(V8ArrayBufferView::toImpl(v8:
:Local<v8::Object>::Cast(v8Body))); | 46 body = FetchFormDataConsumerHandle::create(V8ArrayBufferView::toImpl(v8:
:Local<v8::Object>::Cast(v8Body))); |
46 } else if (V8Blob::hasInstance(v8Body, isolate)) { | 47 } else if (V8Blob::hasInstance(v8Body, isolate)) { |
47 RefPtr<BlobDataHandle> blobDataHandle = V8Blob::toImpl(v8::Local<v8::Obj
ect>::Cast(v8Body))->blobDataHandle(); | 48 RefPtr<BlobDataHandle> blobDataHandle = V8Blob::toImpl(v8::Local<v8::Obj
ect>::Cast(v8Body))->blobDataHandle(); |
48 contentType = blobDataHandle->type(); | 49 contentType = blobDataHandle->type(); |
49 body = FetchBlobDataConsumerHandle::create(context, blobDataHandle.relea
se()); | 50 body = FetchBlobDataConsumerHandle::create(context, blobDataHandle.relea
se()); |
50 } else if (V8FormData::hasInstance(v8Body, isolate)) { | 51 } else if (V8FormData::hasInstance(v8Body, isolate)) { |
51 RefPtr<FormData> formData = V8FormData::toImpl(v8::Local<v8::Object>::Ca
st(v8Body))->createMultiPartFormData(); | 52 RefPtr<FormData> formData = V8FormData::toImpl(v8::Local<v8::Object>::Ca
st(v8Body))->createMultiPartFormData(); |
52 // Here we handle formData->boundary() as a C-style string. See | 53 // Here we handle formData->boundary() as a C-style string. See |
53 // FormDataBuilder::generateUniqueBoundaryString. | 54 // FormDataBuilder::generateUniqueBoundaryString. |
54 contentType = AtomicString("multipart/form-data; boundary=", AtomicStrin
g::ConstructFromLiteral) + formData->boundary().data(); | 55 contentType = AtomicString("multipart/form-data; boundary=", AtomicStrin
g::ConstructFromLiteral) + formData->boundary().data(); |
55 body = FetchFormDataConsumerHandle::create(context, formData.release()); | 56 body = FetchFormDataConsumerHandle::create(context, formData.release()); |
56 } else if (v8Body->IsString()) { | 57 } else if (v8Body->IsString()) { |
57 contentType = "text/plain;charset=UTF-8"; | 58 contentType = "text/plain;charset=UTF-8"; |
58 body = FetchFormDataConsumerHandle::create(toUSVString(isolate, v8Body,
exceptionState)); | 59 body = FetchFormDataConsumerHandle::create(toUSVString(isolate, v8Body,
exceptionState)); |
59 } | 60 } |
60 } | 61 } |
61 | 62 |
62 } | 63 } |
OLD | NEW |