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

Unified Diff: third_party/WebKit/Source/modules/fetch/Response.cpp

Issue 2163273002: [Fetch] Accept URLSearchParams in Response constructor (Closed) Base URL: https://chromium.googlesource.com/chromium/src@master
Patch Set: Created 4 years, 5 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/modules/fetch/Response.cpp
diff --git a/third_party/WebKit/Source/modules/fetch/Response.cpp b/third_party/WebKit/Source/modules/fetch/Response.cpp
index 5ccedd483bf674f6715b0626ca7ef85dc648a640..34fe4c734c081056f41cc16ff62119023a9e28a3 100644
--- a/third_party/WebKit/Source/modules/fetch/Response.cpp
+++ b/third_party/WebKit/Source/modules/fetch/Response.cpp
@@ -13,8 +13,10 @@
#include "bindings/core/v8/V8Blob.h"
#include "bindings/core/v8/V8FormData.h"
#include "bindings/core/v8/V8HiddenValue.h"
+#include "bindings/core/v8/V8URLSearchParams.h"
#include "core/dom/DOMArrayBuffer.h"
#include "core/dom/DOMArrayBufferView.h"
+#include "core/dom/URLSearchParams.h"
#include "core/fileapi/Blob.h"
#include "core/html/FormData.h"
#include "core/streams/ReadableStreamOperations.h"
@@ -143,6 +145,10 @@ Response* Response::create(ScriptState* scriptState, ScriptValue bodyValue, cons
// FormDataEncoder::generateUniqueBoundaryString.
contentType = AtomicString("multipart/form-data; boundary=") + formData->boundary().data();
bodyBuffer = new BodyStreamBuffer(scriptState, FetchFormDataConsumerHandle::create(executionContext, formData.release()));
+ } else if (V8URLSearchParams::hasInstance(body, isolate)) {
+ RefPtr<EncodedFormData> formData = V8URLSearchParams::toImpl(body.As<v8::Object>())->toEncodedFormData();
+ bodyBuffer = new BodyStreamBuffer(scriptState, FetchFormDataConsumerHandle::create(executionContext, formData.release()));
+ contentType = "application/x-www-form-urlencoded;charset=UTF-8";
} else if (RuntimeEnabledFeatures::responseConstructedWithReadableStreamEnabled() && ReadableStreamOperations::isReadableStream(scriptState, bodyValue)) {
if (RuntimeEnabledFeatures::responseBodyWithV8ExtraStreamEnabled()) {
bodyBuffer = new BodyStreamBuffer(scriptState, bodyValue);

Powered by Google App Engine
This is Rietveld 408576698