diff options
author | Simon Hausmann <simon.hausmann@theqtcompany.com> | 2015-04-28 16:03:07 +0200 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@theqtcompany.com> | 2015-05-03 16:33:26 +0000 |
commit | 6c1d99c2490e1af5c42d03cf10e8fe4d2e30c025 (patch) | |
tree | 0249d973d1b99e201463de7e35efb621ff6e044f | |
parent | b999aaaf4e3f4069fb57e016cfa7461eb15e0992 (diff) |
Fix default value for XMLHttpRequest.response property
The default value for responseType is the empty string, for which
the expected data type for the response property is a string - same
as when the response type is set to "text". In other words: By default
the response property should contain the string representation of the
data.
Task-number: QTBUG-45862
Change-Id: I563160e5cdfbf93aca7e283e455d77a6b9deceb4
Reviewed-by: Pasi Keränen <pasi.keranen@digia.com>
Reviewed-by: Valery Kotov <kotov.valery@gmail.com>
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
-rw-r--r-- | src/qml/qml/qqmlxmlhttprequest.cpp | 2 | ||||
-rw-r--r-- | tests/auto/qml/qqmlxmlhttprequest/data/statusText.qml | 2 |
2 files changed, 2 insertions, 2 deletions
diff --git a/src/qml/qml/qqmlxmlhttprequest.cpp b/src/qml/qml/qqmlxmlhttprequest.cpp index a2c5f09061..2a3ede6a22 100644 --- a/src/qml/qml/qqmlxmlhttprequest.cpp +++ b/src/qml/qml/qqmlxmlhttprequest.cpp @@ -1982,7 +1982,7 @@ ReturnedValue QQmlXMLHttpRequestCtor::method_get_response(CallContext *ctx) return QV4::Encode(scope.engine->newString(QString())); const QString& responseType = r->responseType(); - if (responseType.compare(QLatin1String("text"), Qt::CaseInsensitive) == 0) { + if (responseType.compare(QLatin1String("text"), Qt::CaseInsensitive) == 0 || responseType.isEmpty()) { return QV4::Encode(scope.engine->newString(r->responseBody())); } else if (responseType.compare(QLatin1String("arraybuffer"), Qt::CaseInsensitive) == 0) { return QV4::Encode(scope.engine->newArrayBuffer(r->rawResponseBody())); diff --git a/tests/auto/qml/qqmlxmlhttprequest/data/statusText.qml b/tests/auto/qml/qqmlxmlhttprequest/data/statusText.qml index bf59a1e9f9..b47a0f1af0 100644 --- a/tests/auto/qml/qqmlxmlhttprequest/data/statusText.qml +++ b/tests/auto/qml/qqmlxmlhttprequest/data/statusText.qml @@ -48,7 +48,7 @@ QtObject { if (x.statusText == expectedStatus) done = true; - dataOK = (x.responseText == "QML Rocks!\n"); + dataOK = (x.responseText == "QML Rocks!\n") && (x.response == "QML Rocks!\n"); x.open("GET", url); x.setRequestHeader("Accept-Language", "en-US"); |