|
|
Chromium Code Reviews
DescriptionSupport XMLHttpRequest.send(URLSearchParams)
Update send()'s overloaded set to also include URLSearchParams,
mirroring a recent BodyInit spec addition,
https://fetch.spec.whatwg.org/#bodyinit
R=yhirano,tyoshino
BUG=694449
Patch Set 1 #
Total comments: 5
Patch Set 2 : factor out Content-Type + charset updating #Patch Set 3 : rebased upto 453904 #Patch Set 4 : rebased upto r454567 #
Messages
Total messages: 35 (22 generated)
The CQ bit was checked by sigbjornf@opera.com to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
Description was changed from ========== Support XMLHttpRequest.send(URLSearchParams) Update send()'s overloaded set to also include URLSearchParams, which the spec now includes in BodyInit, https://fetch.spec.whatwg.org/#bodyinit R= BUG=694449 ========== to ========== Support XMLHttpRequest.send(URLSearchParams) Update send()'s overloaded set to also include URLSearchParams, mirroring a recent BodyInit spec addition, https://fetch.spec.whatwg.org/#bodyinit R= BUG=694449 ==========
sigbjornf@opera.com changed reviewers: + tyoshino@chromium.org, yhirano@chromium.org
please take a look. (importing wpt's XHR tests would be a fine thing to do, but not here.)
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: This issue passed the CQ dry run.
https://codereview.chromium.org/2723583005/diff/1/third_party/WebKit/Source/c... File third_party/WebKit/Source/core/xmlhttprequest/XMLHttpRequest.cpp (right): https://codereview.chromium.org/2723583005/diff/1/third_party/WebKit/Source/c... third_party/WebKit/Source/core/xmlhttprequest/XMLHttpRequest.cpp:886: replaceCharsetInMediaType(contentType, "UTF-8"); Can you tell me where this is from?
https://codereview.chromium.org/2723583005/diff/1/third_party/WebKit/Source/c... File third_party/WebKit/Source/core/xmlhttprequest/XMLHttpRequest.cpp (right): https://codereview.chromium.org/2723583005/diff/1/third_party/WebKit/Source/c... third_party/WebKit/Source/core/xmlhttprequest/XMLHttpRequest.cpp:886: replaceCharsetInMediaType(contentType, "UTF-8"); On 2017/03/01 02:21:00, yhirano (slow) wrote: > Can you tell me where this is from? Last para of step 4 in https://xhr.spec.whatwg.org/#the-send%28%29-method
https://codereview.chromium.org/2723583005/diff/1/third_party/WebKit/LayoutTe... File third_party/WebKit/LayoutTests/http/tests/xmlhttprequest/resources/echo-content.php (right): https://codereview.chromium.org/2723583005/diff/1/third_party/WebKit/LayoutTe... third_party/WebKit/LayoutTests/http/tests/xmlhttprequest/resources/echo-content.php:4: ?> Can http/tests/xmlhttprequest/resources/post-echo.php serve this needs? https://codereview.chromium.org/2723583005/diff/1/third_party/WebKit/Source/c... File third_party/WebKit/Source/core/xmlhttprequest/XMLHttpRequest.cpp (right): https://codereview.chromium.org/2723583005/diff/1/third_party/WebKit/Source/c... third_party/WebKit/Source/core/xmlhttprequest/XMLHttpRequest.cpp:886: replaceCharsetInMediaType(contentType, "UTF-8"); On 2017/03/01 07:07:52, sof wrote: > On 2017/03/01 02:21:00, yhirano (slow) wrote: > > Can you tell me where this is from? > > Last para of step 4 in https://xhr.spec.whatwg.org/#the-send%28%29-method Can we factor this out? XMLHttpRequest::send(const String&, ...) has the same logic.
lgtm
The CQ bit was checked by sigbjornf@opera.com to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
https://codereview.chromium.org/2723583005/diff/1/third_party/WebKit/Source/c... File third_party/WebKit/Source/core/xmlhttprequest/XMLHttpRequest.cpp (right): https://codereview.chromium.org/2723583005/diff/1/third_party/WebKit/Source/c... third_party/WebKit/Source/core/xmlhttprequest/XMLHttpRequest.cpp:886: replaceCharsetInMediaType(contentType, "UTF-8"); On 2017/03/01 09:04:58, tyoshino wrote: > On 2017/03/01 07:07:52, sof wrote: > > On 2017/03/01 02:21:00, yhirano (slow) wrote: > > > Can you tell me where this is from? > > > > Last para of step 4 in https://xhr.spec.whatwg.org/#the-send%28%29-method > > Can we factor this out? XMLHttpRequest::send(const String&, ...) has the same > logic. Oh yes, good suggestion; done + added a test.
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: This issue passed the CQ dry run.
The CQ bit was checked by sigbjornf@opera.com to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: Try jobs failed on following builders: linux_android_rel_ng on master.tryserver.chromium.android (JOB_FAILED, https://build.chromium.org/p/tryserver.chromium.android/builders/linux_androi...)
Description was changed from ========== Support XMLHttpRequest.send(URLSearchParams) Update send()'s overloaded set to also include URLSearchParams, mirroring a recent BodyInit spec addition, https://fetch.spec.whatwg.org/#bodyinit R= BUG=694449 ========== to ========== Support XMLHttpRequest.send(URLSearchParams) Update send()'s overloaded set to also include URLSearchParams, mirroring a recent BodyInit spec addition, https://fetch.spec.whatwg.org/#bodyinit R=yhirano,tyoshino BUG=694449 ==========
ps#3 ready?
landing, will handle anything remaining in a followup.
The CQ bit was checked by sigbjornf@opera.com
The patchset sent to the CQ was uploaded after l-g-t-m from yhirano@chromium.org Link to the patchset: https://codereview.chromium.org/2723583005/#ps40001 (title: "rebased upto 453904")
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
The CQ bit was unchecked by commit-bot@chromium.org
Failed to apply patch for
third_party/WebKit/Source/core/xmlhttprequest/XMLHttpRequest.cpp:
While running git apply --index -p1;
error: patch failed:
third_party/WebKit/Source/core/xmlhttprequest/XMLHttpRequest.cpp:704
error: third_party/WebKit/Source/core/xmlhttprequest/XMLHttpRequest.cpp: patch
does not apply
Patch: third_party/WebKit/Source/core/xmlhttprequest/XMLHttpRequest.cpp
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
df87ca6179e6c9fede8dae4c685078571f7ee520..004dc8bbab8e40a61cc3437d564051e9c939c871
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);
}
@@ -785,17 +792,9 @@ void XMLHttpRequest::send(const String& body,
ExceptionState& exceptionState) {
RefPtr<EncodedFormData> httpBody;
if (!body.isNull() && areMethodAndURLValidForSend()) {
- String contentType = getRequestHeader(HTTPNames::Content_Type);
- if (contentType.isEmpty()) {
- setRequestHeaderInternal(HTTPNames::Content_Type,
- "text/plain;charset=UTF-8");
- } else {
- replaceCharsetInMediaType(contentType, "UTF-8");
- m_requestHeaders.set(HTTPNames::Content_Type, AtomicString(contentType));
- }
-
httpBody = EncodedFormData::create(
UTF8Encoding().encode(body, WTF::EntitiesForUnencodables));
+ updateContentTypeAndCharset("text/plain;charset=UTF-8", "UTF-8");
}
createRequest(std::move(httpBody), exceptionState);
@@ -847,6 +846,8 @@ void XMLHttpRequest::send(FormData* body, ExceptionState&
exceptionState) {
if (areMethodAndURLValidForSend()) {
httpBody = body->encodeMultiPartFormData();
+ // TODO (sof): override any author-provided charset= in the
+ // content type value to UTF-8 ?
if (getRequestHeader(HTTPNames::Content_Type).isEmpty()) {
AtomicString contentType =
AtomicString("multipart/form-data; boundary=") +
@@ -858,6 +859,24 @@ 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();
+ updateContentTypeAndCharset(
+ "application/x-www-form-urlencoded;charset=UTF-8", "UTF-8");
+ }
+
+ createRequest(std::move(httpBody), exceptionState);
+}
+
void XMLHttpRequest::send(DOMArrayBuffer* body,
ExceptionState& exceptionState) {
NETWORK_DVLOG(1) << this << " send() ArrayBuffer " << body;
@@ -1446,6 +1465,20 @@ AtomicString
XMLHttpRequest::finalResponseMIMETypeWithFallback() const {
return AtomicString("text/xml");
}
+void XMLHttpRequest::updateContentTypeAndCharset(
+ const AtomicString& defaultContentType,
+ const String& charset) {
+ // http://xhr.spec.whatwg.org/#the-send()-method step 4's concilliation of
+ // "charset=" in any author-provided Content-Type: request header.
+ String contentType = getRequestHeader(HTTPNames::Content_Type);
+ if (contentType.isEmpty()) {
+ setRequestHeaderInternal(HTTPNames::Content_Type, defaultContentType);
+ return;
+ }
+ replaceCharsetInMediaType(contentType, charset);
+ m_requestHeaders.set(HTTPNames::Content_Type, AtomicString(contentType));
+}
+
bool XMLHttpRequest::responseIsXML() const {
return DOMImplementation::isXMLMIMEType(finalResponseMIMETypeWithFallback());
}
The CQ bit was checked by sigbjornf@opera.com
The patchset sent to the CQ was uploaded after l-g-t-m from yhirano@chromium.org Link to the patchset: https://codereview.chromium.org/2723583005/#ps60001 (title: "rebased upto r454567")
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
CQ is committing da patch.
Bot data: {"patchset_id": 60001, "attempt_start_ts": 1488542518943720,
"parent_rev": "3263a553bc0f2e750972280cc70318bd09bdeb76", "commit_rev":
"c738672e528bf6262182e9aebf7f3b1ad3dbcee0"}
The CQ bit was unchecked by commit-bot@chromium.org
Prior attempt to commit was detected, but we were not able to check whether the issue was successfully committed. Please check Git history manually and re-check CQ or close this issue as needed.
On 2017/03/03 13:35:59, commit-bot: I haz the power wrote: > Prior attempt to commit was detected, but we were not able to check whether the > issue was successfully committed. Please check Git history manually and re-check > CQ or close this issue as needed. Not run into this one before (prior attempt failed due to patch failure). In any case, this CL landed at https://chromium.googlesource.com/chromium/src/+/c738672e528bf6262182e9aebf7f... (r454571) |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
