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

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: var => const, an => a, -TODO 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
« no previous file with comments | « third_party/WebKit/LayoutTests/http/tests/fetch/script-tests/response-content.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..76af6c3b7a532a5e1c1de7a753f6d9565f27a625 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);
@@ -165,7 +171,6 @@ Response* Response::create(ScriptState* scriptState, ScriptValue bodyValue, cons
bodyBuffer = new BodyStreamBuffer(scriptState, FetchFormDataConsumerHandle::create(string));
contentType = "text/plain;charset=UTF-8";
}
- // TODO(yhirano): Add the URLSearchParams case.
Response* response = create(scriptState, bodyBuffer, contentType, ResponseInit(init, exceptionState), exceptionState);
if (!exceptionState.hadException() && !reader.isEmpty()) {
// Add a hidden reference so that the weak persistent in the
« no previous file with comments | « third_party/WebKit/LayoutTests/http/tests/fetch/script-tests/response-content.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698