Index: third_party/WebKit/Source/core/xmlhttprequest/XMLHttpRequest.cpp |
diff --git a/third_party/WebKit/Source/core/xmlhttprequest/XMLHttpRequest.cpp b/third_party/WebKit/Source/core/xmlhttprequest/XMLHttpRequest.cpp |
index 98d47e7fd8b5436ca0ea5a49d544f8b0e1593bd4..600f69a863a080fd0a9378e97075e37988149225 100644 |
--- a/third_party/WebKit/Source/core/xmlhttprequest/XMLHttpRequest.cpp |
+++ b/third_party/WebKit/Source/core/xmlhttprequest/XMLHttpRequest.cpp |
@@ -23,7 +23,8 @@ |
#include "core/xmlhttprequest/XMLHttpRequest.h" |
-#include "bindings/core/v8/ArrayBufferOrArrayBufferViewOrBlobOrDocumentOrStringOrFormData.h" |
+#include <memory> |
+#include "bindings/core/v8/ArrayBufferOrArrayBufferViewOrBlobOrDocumentOrStringOrFormDataOrURLSearchParams.h" |
#include "bindings/core/v8/ArrayBufferOrArrayBufferViewOrBlobOrUSVString.h" |
#include "bindings/core/v8/DOMWrapperWorld.h" |
#include "bindings/core/v8/ExceptionState.h" |
@@ -37,6 +38,7 @@ |
#include "core/dom/DocumentParser.h" |
#include "core/dom/ExceptionCode.h" |
#include "core/dom/ExecutionContext.h" |
+#include "core/dom/URLSearchParams.h" |
#include "core/dom/XMLDocument.h" |
#include "core/editing/serializers/Serialization.h" |
#include "core/events/Event.h" |
@@ -81,7 +83,6 @@ |
#include "wtf/AutoReset.h" |
#include "wtf/StdLibExtras.h" |
#include "wtf/text/CString.h" |
-#include <memory> |
namespace blink { |
@@ -704,7 +705,8 @@ bool XMLHttpRequest::initSend(ExceptionState& exceptionState) { |
} |
void XMLHttpRequest::send( |
- const ArrayBufferOrArrayBufferViewOrBlobOrDocumentOrStringOrFormData& body, |
+ const ArrayBufferOrArrayBufferViewOrBlobOrDocumentOrStringOrFormDataOrURLSearchParams& |
+ body, |
ExceptionState& exceptionState) { |
InspectorInstrumentation::willSendXMLHttpOrFetchNetworkRequest( |
getExecutionContext(), url()); |
@@ -739,6 +741,11 @@ void XMLHttpRequest::send( |
return; |
} |
+ if (body.isURLSearchParams()) { |
+ send(body.getAsURLSearchParams(), exceptionState); |
+ return; |
+ } |
+ |
DCHECK(body.isString()); |
send(body.getAsString(), exceptionState); |
} |
@@ -858,6 +865,32 @@ void XMLHttpRequest::send(FormData* body, ExceptionState& exceptionState) { |
createRequest(std::move(httpBody), exceptionState); |
} |
+void XMLHttpRequest::send(URLSearchParams* body, |
+ ExceptionState& exceptionState) { |
+ NETWORK_DVLOG(1) << this << " send() URLSearchParams " << body; |
+ |
+ if (!initSend(exceptionState)) |
+ return; |
+ |
+ RefPtr<EncodedFormData> httpBody; |
+ |
+ if (areMethodAndURLValidForSend()) { |
+ httpBody = body->toEncodedFormData(); |
+ |
+ String contentType = getRequestHeader(HTTPNames::Content_Type); |
+ if (contentType.isEmpty()) { |
+ setRequestHeaderInternal( |
+ HTTPNames::Content_Type, |
+ "application/x-www-form-urlencoded;charset=UTF-8"); |
+ } else { |
+ replaceCharsetInMediaType(contentType, "UTF-8"); |
yhirano
2017/03/01 02:21:00
Can you tell me where this is from?
sof
2017/03/01 07:07:52
Last para of step 4 in https://xhr.spec.whatwg.org
tyoshino (SeeGerritForStatus)
2017/03/01 09:04:58
Can we factor this out? XMLHttpRequest::send(const
sof
2017/03/01 09:49:14
Oh yes, good suggestion; done + added a test.
|
+ m_requestHeaders.set(HTTPNames::Content_Type, AtomicString(contentType)); |
+ } |
+ } |
+ |
+ createRequest(std::move(httpBody), exceptionState); |
+} |
+ |
void XMLHttpRequest::send(DOMArrayBuffer* body, |
ExceptionState& exceptionState) { |
NETWORK_DVLOG(1) << this << " send() ArrayBuffer " << body; |