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 RefPtr<FormData> formData = FormData::create(); | 42 RefPtr<FormData> formData = FormData::create(); |
42 v8::Isolate* isolate = toIsolate(context); | 43 v8::Isolate* isolate = toIsolate(context); |
43 if (v8Body->IsArrayBuffer()) { | 44 if (v8Body->IsArrayBuffer()) { |
44 body = FetchFormDataConsumerHandle::create(V8ArrayBuffer::toImpl(v8::Loc
al<v8::Object>::Cast(v8Body))); | 45 body = FetchFormDataConsumerHandle::create(V8ArrayBuffer::toImpl(v8::Loc
al<v8::Object>::Cast(v8Body))); |
45 } else if (v8Body->IsArrayBufferView()) { | 46 } else if (v8Body->IsArrayBufferView()) { |
46 body = FetchFormDataConsumerHandle::create(V8ArrayBufferView::toImpl(v8:
:Local<v8::Object>::Cast(v8Body))); | 47 body = FetchFormDataConsumerHandle::create(V8ArrayBufferView::toImpl(v8:
:Local<v8::Object>::Cast(v8Body))); |
47 } else if (V8Blob::hasInstance(v8Body, isolate)) { | 48 } else if (V8Blob::hasInstance(v8Body, isolate)) { |
48 RefPtr<BlobDataHandle> blobDataHandle = V8Blob::toImpl(v8::Local<v8::Obj
ect>::Cast(v8Body))->blobDataHandle(); | 49 RefPtr<BlobDataHandle> blobDataHandle = V8Blob::toImpl(v8::Local<v8::Obj
ect>::Cast(v8Body))->blobDataHandle(); |
49 contentType = blobDataHandle->type(); | 50 contentType = blobDataHandle->type(); |
50 body = FetchBlobDataConsumerHandle::create(context, blobDataHandle.relea
se()); | 51 body = FetchBlobDataConsumerHandle::create(context, blobDataHandle.relea
se()); |
51 } else if (V8FormData::hasInstance(v8Body, isolate)) { | 52 } else if (V8FormData::hasInstance(v8Body, isolate)) { |
52 RefPtr<FormData> formData = V8FormData::toImpl(v8::Local<v8::Object>::Ca
st(v8Body))->createMultiPartFormData(); | 53 RefPtr<FormData> formData = V8FormData::toImpl(v8::Local<v8::Object>::Ca
st(v8Body))->createMultiPartFormData(); |
53 // Here we handle formData->boundary() as a C-style string. See | 54 // Here we handle formData->boundary() as a C-style string. See |
54 // FormDataBuilder::generateUniqueBoundaryString. | 55 // FormDataBuilder::generateUniqueBoundaryString. |
55 contentType = AtomicString("multipart/form-data; boundary=", AtomicStrin
g::ConstructFromLiteral) + formData->boundary().data(); | 56 contentType = AtomicString("multipart/form-data; boundary=", AtomicStrin
g::ConstructFromLiteral) + formData->boundary().data(); |
56 body = FetchFormDataConsumerHandle::create(context, formData.release()); | 57 body = FetchFormDataConsumerHandle::create(context, formData.release()); |
57 } else if (v8Body->IsString()) { | 58 } else if (v8Body->IsString()) { |
58 contentType = "text/plain;charset=UTF-8"; | 59 contentType = "text/plain;charset=UTF-8"; |
59 body = FetchFormDataConsumerHandle::create(toUSVString(isolate, v8Body,
exceptionState)); | 60 body = FetchFormDataConsumerHandle::create(toUSVString(isolate, v8Body,
exceptionState)); |
60 } | 61 } |
61 } | 62 } |
62 | 63 |
63 } | 64 } |
OLD | NEW |