diff options
author | Topi Reinio <topi.reinio@nokia.com> | 2012-04-18 14:55:02 +0200 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-05-01 06:06:51 +0200 |
commit | 0949071f13e7bcbc16a0f07f496e0b6a23b04edd (patch) | |
tree | 26aba383a6484a455874cb9d8b0f561598e51ae3 /tests/auto/qml/qqmlxmlhttprequest | |
parent | e39908c658c6caa2013bc7356eb904b669af1bfb (diff) |
Keep XMLHttpRequest response data after receiving a server error
Fix XMLHttpRequest.responseText being set to empty string whenever a
server status code other than '200/OK' is received. XMLHttpRequest
specification says that response entity body is to be returned unless
the error flag is set, and the flag is set only in case of abort() or
network error. This change enables clients to receive additional error
information the server may return in the response body.
http://www.w3.org/TR/XMLHttpRequest/#the-responsetext-attribute
Task-number: QTBUG-21706
Change-Id: I7e44f481494dc7eddea3868d6f92ee45d7ab0c69
Reviewed-by: Yunqiao Yin <charles.yin@nokia.com>
Reviewed-by: Bea Lam <bea.lam@nokia.com>
Diffstat (limited to 'tests/auto/qml/qqmlxmlhttprequest')
4 files changed, 4 insertions, 13 deletions
diff --git a/tests/auto/qml/qqmlxmlhttprequest/data/status.400.reply b/tests/auto/qml/qqmlxmlhttprequest/data/status.400.reply index e3f6944173..c158fbb33d 100644 --- a/tests/auto/qml/qqmlxmlhttprequest/data/status.400.reply +++ b/tests/auto/qml/qqmlxmlhttprequest/data/status.400.reply @@ -1,4 +1,3 @@ HTTP/1.0 400 Bad request Connection: close Content-type: text/html; charset=UTF-8 - diff --git a/tests/auto/qml/qqmlxmlhttprequest/data/status.qml b/tests/auto/qml/qqmlxmlhttprequest/data/status.qml index f5e10d79ad..5feac17711 100644 --- a/tests/auto/qml/qqmlxmlhttprequest/data/status.qml +++ b/tests/auto/qml/qqmlxmlhttprequest/data/status.qml @@ -48,11 +48,7 @@ QtObject { if (x.status == expectedStatus) done = true; - if (expectedStatus != 200) { - dataOK = (x.responseText == ""); - } else { - dataOK = (x.responseText == "QML Rocks!\n"); - } + dataOK = (x.responseText == "QML Rocks!\n"); x.open("GET", url); x.setRequestHeader("Accept-Language", "en-US"); diff --git a/tests/auto/qml/qqmlxmlhttprequest/data/statusText.qml b/tests/auto/qml/qqmlxmlhttprequest/data/statusText.qml index e7f658fc29..3c74efc091 100644 --- a/tests/auto/qml/qqmlxmlhttprequest/data/statusText.qml +++ b/tests/auto/qml/qqmlxmlhttprequest/data/statusText.qml @@ -48,11 +48,7 @@ QtObject { if (x.statusText == expectedStatus) done = true; - if (expectedStatus != "OK") { - dataOK = (x.responseText == ""); - } else { - dataOK = (x.responseText == "QML Rocks!\n"); - } + dataOK = (x.responseText == "QML Rocks!\n"); x.open("GET", url); x.setRequestHeader("Accept-Language", "en-US"); diff --git a/tests/auto/qml/qqmlxmlhttprequest/tst_qqmlxmlhttprequest.cpp b/tests/auto/qml/qqmlxmlhttprequest/tst_qqmlxmlhttprequest.cpp index f8d74c3cde..7a65308b6e 100644 --- a/tests/auto/qml/qqmlxmlhttprequest/tst_qqmlxmlhttprequest.cpp +++ b/tests/auto/qml/qqmlxmlhttprequest/tst_qqmlxmlhttprequest.cpp @@ -937,8 +937,8 @@ void tst_qqmlxmlhttprequest::responseText_data() QTest::newRow("OK") << testFileUrl("status.200.reply") << testFileUrl("testdocument.html") << "QML Rocks!\n"; QTest::newRow("empty body") << testFileUrl("status.200.reply") << QUrl() << ""; - QTest::newRow("Not Found") << testFileUrl("status.404.reply") << testFileUrl("testdocument.html") << ""; - QTest::newRow("Bad Request") << testFileUrl("status.404.reply") << testFileUrl("testdocument.html") << ""; + QTest::newRow("Not Found") << testFileUrl("status.404.reply") << testFileUrl("testdocument.html") << "QML Rocks!\n"; + QTest::newRow("Bad Request") << testFileUrl("status.400.reply") << testFileUrl("testdocument.html") << "QML Rocks!\n"; } void tst_qqmlxmlhttprequest::nonUtf8() |