mirror of
https://github.com/lubosz/overte.git
synced 2025-04-24 12:43:19 +02:00
Add arraybuffer binary data handling in JavaScript XMLHttpRequest
This commit is contained in:
parent
33ffed7135
commit
d05435db91
2 changed files with 10 additions and 5 deletions
|
@ -194,10 +194,10 @@ void XMLHttpRequestClass::open(const QString& method, const QString& url, bool a
|
|||
}
|
||||
|
||||
void XMLHttpRequestClass::send() {
|
||||
send(QString::Null());
|
||||
send(QString());
|
||||
}
|
||||
|
||||
void XMLHttpRequestClass::send(const QString& data) {
|
||||
void XMLHttpRequestClass::send(const QVariant& data) {
|
||||
if (_readyState == OPENED && !_reply) {
|
||||
if (!data.isNull()) {
|
||||
if (_url.isLocalFile()) {
|
||||
|
@ -205,7 +205,12 @@ void XMLHttpRequestClass::send(const QString& data) {
|
|||
return;
|
||||
} else {
|
||||
_sendData = new QBuffer(this);
|
||||
_sendData->setData(data.toUtf8());
|
||||
if (_responseType == "arraybuffer") {
|
||||
QByteArray ba = qvariant_cast<QByteArray>(data);
|
||||
_sendData->setData(ba);
|
||||
} else {
|
||||
_sendData->setData(data.toString().toUtf8());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -274,7 +279,7 @@ void XMLHttpRequestClass::requestFinished() {
|
|||
_responseData = QScriptValue::NullValue;
|
||||
}
|
||||
} else if (_responseType == "arraybuffer") {
|
||||
_responseData = QScriptValue(_rawResponseData.data());
|
||||
_responseData = _engine->newVariant(QVariant::fromValue(_rawResponseData));
|
||||
} else {
|
||||
_responseData = QScriptValue(QString(_rawResponseData.data()));
|
||||
}
|
||||
|
|
|
@ -84,7 +84,7 @@ public slots:
|
|||
void open(const QString& method, const QString& url, bool async = true, const QString& username = "",
|
||||
const QString& password = "");
|
||||
void send();
|
||||
void send(const QString& data);
|
||||
void send(const QVariant& data);
|
||||
QScriptValue getAllResponseHeaders() const;
|
||||
QScriptValue getResponseHeader(const QString& name) const;
|
||||
|
||||
|
|
Loading…
Reference in a new issue