Hi,
I think send() should be fixed to support more than just strings as parameters. For example in browsers you can use send() with array buffers and blob objects. We don't support the latter, but the former we do and they are also our mapping for QByteArray. Want to give it a try? It should be a relatively straight-forward change and we have good XHR test coverage, so it should be easy to extend the tests to cover this. Simon ________________________________ From: Development <[email protected]> on behalf of Alberto Mardegan <[email protected]> Sent: Thursday, June 22, 2017 11:20:39 PM To: [email protected] Subject: [Development] XMLHttpRequest.send() with arbitrary data Hi all, my understanding looking at the implementation of the XMLHttpRequest.send() method in QtDeclarative [1] is that the said method only accepts UTF-8 data as parameter. Now, I would like to be able to send arbitrary data (in order to, for example, upload a JPEG image to flickr) and I believe that the limitation above is preventing me from doing so: my QByteArray (which I'm actually preparing from the C++ side and then converting into a QString with QString::fromUtf8()) is not being transmitted properly. No surprise here, as I understand that the QString::fromUtf8() method will stop as soon as a zero byte is found. But than, what is the way forward? I see that javascript has some more types such as Blob and ArrayBufferView, which at least judging by the name could be suitable types for transporting binary data. I see that there is a newArrayBuffer() method in QJSEngine's private class; would exporting that to the client help in any way? Or should the implementation of XMLHttpRequest.send() try to first convert its parameter to a QByteArray (via QJSValue::fromScriptValue()) and only fallback to QString if that fails? Ciao, Alberto [1]: http://code.qt.io/cgit/qt/qtdeclarative.git/tree/src/qml/qml/qqmlxmlhttprequest.cpp?h=dev#n1814 _______________________________________________ Development mailing list [email protected] http://lists.qt-project.org/mailman/listinfo/development
_______________________________________________ Development mailing list [email protected] http://lists.qt-project.org/mailman/listinfo/development
