aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAlberto Mardegan <mardy@users.sourceforge.net>2017-06-23 23:26:35 +0200
committerAlberto Mardegan <mardy@users.sourceforge.net>2017-06-26 14:10:54 +0000
commit5c80b29e6d77f0ebc63832473159f5a39babe21b (patch)
treeef09fa303544eb26bd9ff5bcdeb5c465e9932e52 /src
parent4beee1a6dcc1be57aa6fb2a175dadc6ff298545d (diff)
QQmlXMLHttpRequest: support sending ArrayBuffer data
The XMLHttpRequest.send() method should be able to send arbitrary binary data, and not just UTF-8 text: with this change we first attempt to use the parameter to the send() method as an ArrayBuffer, and fall back to a QString if that fails. [ChangeLog][QtQml] Allow sending binary data, encoded as ArrayBuffer objects, via XMLHttpRequest's send() method. Task-number: QTBUG-61599 Change-Id: I25781969ee39b4d168e5c76315ed9853092b322b Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'src')
-rw-r--r--src/qml/qml/qqmlxmlhttprequest.cpp9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/qml/qml/qqmlxmlhttprequest.cpp b/src/qml/qml/qqmlxmlhttprequest.cpp
index 9e8735cbc6..113ef0c412 100644
--- a/src/qml/qml/qqmlxmlhttprequest.cpp
+++ b/src/qml/qml/qqmlxmlhttprequest.cpp
@@ -1823,8 +1823,13 @@ void QQmlXMLHttpRequestCtor::method_send(const QV4::BuiltinFunction *, QV4::Scop
THROW_DOM(DOMEXCEPTION_INVALID_STATE_ERR, "Invalid state");
QByteArray data;
- if (callData->argc > 0)
- data = callData->args[0].toQStringNoThrow().toUtf8();
+ if (callData->argc > 0) {
+ if (const ArrayBuffer *buffer = callData->args[0].as<ArrayBuffer>()) {
+ data = buffer->asByteArray();
+ } else {
+ data = callData->args[0].toQStringNoThrow().toUtf8();
+ }
+ }
scope.result = r->send(w, scope.engine->callingQmlContext(), data);
}