diff options
author | Charles Yin <charles.yin@nokia.com> | 2011-07-27 09:57:37 +1000 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2011-07-28 07:12:34 +0200 |
commit | 14496b18a67982ee25ed43aed6b6bcd7d6fa23ee (patch) | |
tree | c52c7ab1639a691308da90e3e628d31e14559186 /tests | |
parent | 44e58a337a9c314d4542ee6f2acc571aba877ccb (diff) |
Fix XmlHttpRequest setHeader bug
Setting XMLHttpRequest raw header makes header name uppercase, the name
should be kept as it is.
Task-number:QTBUG-20472
Change-Id: I8aa8988d6d18d71ee71a7d2f9c3246b20f006f3c
Reviewed-on: http://codereview.qt.nokia.com/2225
Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com>
Reviewed-by: Aaron Kennedy <aaron.kennedy@nokia.com>
Diffstat (limited to 'tests')
13 files changed, 63 insertions, 13 deletions
diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/abort.expect b/tests/auto/declarative/qdeclarativexmlhttprequest/data/abort.expect index 3ed1f7f3b0..d6951a8255 100644 --- a/tests/auto/declarative/qdeclarativexmlhttprequest/data/abort.expect +++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/abort.expect @@ -1,5 +1,5 @@ PUT /testdocument.html HTTP/1.1 -ACCEPT-LANGUAGE: en-US +Accept-Language: en-US Content-Type: text/plain;charset=UTF-8 Content-Length: 9 Connection: Keep-Alive diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/getResponseHeader.expect b/tests/auto/declarative/qdeclarativexmlhttprequest/data/getResponseHeader.expect index 4d940c29c3..cf5830ed0c 100644 --- a/tests/auto/declarative/qdeclarativexmlhttprequest/data/getResponseHeader.expect +++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/getResponseHeader.expect @@ -1,5 +1,5 @@ GET /testdocument.html HTTP/1.1 -ACCEPT-LANGUAGE: en-US +Accept-Language: en-US Connection: Keep-Alive Accept-Encoding: gzip, deflate User-Agent: Mozilla/5.0 diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/open_network.expect b/tests/auto/declarative/qdeclarativexmlhttprequest/data/open_network.expect index 4d940c29c3..cf5830ed0c 100644 --- a/tests/auto/declarative/qdeclarativexmlhttprequest/data/open_network.expect +++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/open_network.expect @@ -1,5 +1,5 @@ GET /testdocument.html HTTP/1.1 -ACCEPT-LANGUAGE: en-US +Accept-Language: en-US Connection: Keep-Alive Accept-Encoding: gzip, deflate User-Agent: Mozilla/5.0 diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/send_data.1.expect b/tests/auto/declarative/qdeclarativexmlhttprequest/data/send_data.1.expect index 98dbbdcb76..9c07d4b633 100644 --- a/tests/auto/declarative/qdeclarativexmlhttprequest/data/send_data.1.expect +++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/send_data.1.expect @@ -1,5 +1,5 @@ POST /testdocument.html HTTP/1.1 -ACCEPT-LANGUAGE: en-US +Accept-Language: en-US Content-Type: text/plain;charset=UTF-8 Content-Length: 12 Connection: Keep-Alive diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/send_data.4.expect b/tests/auto/declarative/qdeclarativexmlhttprequest/data/send_data.4.expect index 5f71adfe7e..c2aba77881 100644 --- a/tests/auto/declarative/qdeclarativexmlhttprequest/data/send_data.4.expect +++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/send_data.4.expect @@ -1,5 +1,5 @@ POST /testdocument.html HTTP/1.1 -ACCEPT-LANGUAGE: en-US +Accept-Language: en-US Content-Type: charset=UTF-8;text/plain Content-Length: 12 Connection: Keep-Alive diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/send_data.6.expect b/tests/auto/declarative/qdeclarativexmlhttprequest/data/send_data.6.expect index 144283aa7e..b09b1bcec5 100644 --- a/tests/auto/declarative/qdeclarativexmlhttprequest/data/send_data.6.expect +++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/send_data.6.expect @@ -1,5 +1,5 @@ PUT /testdocument.html HTTP/1.1 -ACCEPT-LANGUAGE: en-US +Accept-Language: en-US Content-Type: text/plain;charset=UTF-8 Content-Length: 12 Connection: Keep-Alive diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/send_ignoreData_DELETE.expect b/tests/auto/declarative/qdeclarativexmlhttprequest/data/send_ignoreData_DELETE.expect index a0a8f4cf9f..dd86b837f4 100644 --- a/tests/auto/declarative/qdeclarativexmlhttprequest/data/send_ignoreData_DELETE.expect +++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/send_ignoreData_DELETE.expect @@ -1,5 +1,5 @@ DELETE /testdocument.html HTTP/1.1 -ACCEPT-LANGUAGE: en-US +Accept-Language: en-US Connection: Keep-Alive Accept-Encoding: gzip, deflate User-Agent: Mozilla/5.0 diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/send_ignoreData_GET.expect b/tests/auto/declarative/qdeclarativexmlhttprequest/data/send_ignoreData_GET.expect index 4d940c29c3..cf5830ed0c 100644 --- a/tests/auto/declarative/qdeclarativexmlhttprequest/data/send_ignoreData_GET.expect +++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/send_ignoreData_GET.expect @@ -1,5 +1,5 @@ GET /testdocument.html HTTP/1.1 -ACCEPT-LANGUAGE: en-US +Accept-Language: en-US Connection: Keep-Alive Accept-Encoding: gzip, deflate User-Agent: Mozilla/5.0 diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/send_ignoreData_HEAD.expect b/tests/auto/declarative/qdeclarativexmlhttprequest/data/send_ignoreData_HEAD.expect index cf13b54f3e..7b7b282660 100644 --- a/tests/auto/declarative/qdeclarativexmlhttprequest/data/send_ignoreData_HEAD.expect +++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/send_ignoreData_HEAD.expect @@ -1,5 +1,5 @@ HEAD /testdocument.html HTTP/1.1 -ACCEPT-LANGUAGE: en-US +Accept-Language: en-US Connection: Keep-Alive Accept-Encoding: gzip, deflate User-Agent: Mozilla/5.0 diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/setRequestHeader.expect b/tests/auto/declarative/qdeclarativexmlhttprequest/data/setRequestHeader.expect index cd13443747..e7f8e10780 100644 --- a/tests/auto/declarative/qdeclarativexmlhttprequest/data/setRequestHeader.expect +++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/setRequestHeader.expect @@ -1,7 +1,7 @@ GET /testdocument.html HTTP/1.1 -ACCEPT-LANGUAGE: en-US -TEST-HEADER: value -TEST-HEADER2: value,value2 +Accept-Language: en-US +Test-header: value +Test-header2: value,value2 Connection: Keep-Alive Accept-Encoding: gzip, deflate User-Agent: Mozilla/5.0 diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/setRequestHeader_caseInsensitive.qml b/tests/auto/declarative/qdeclarativexmlhttprequest/data/setRequestHeader_caseInsensitive.qml new file mode 100644 index 0000000000..e03f73431a --- /dev/null +++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/setRequestHeader_caseInsensitive.qml @@ -0,0 +1,30 @@ +import QtQuick 2.0 + +QtObject { + property string url + + property bool dataOK: false + + Component.onCompleted: { + var x = new XMLHttpRequest; + + x.open("GET", url); + x.setRequestHeader("Accept-Language","en-US"); + + x.setRequestHeader("Test-header", "value"); + //Setting headers with just different cases + //will be treated as the same header, and accepted + //as the last setting. + x.setRequestHeader("Test-hEADEr2", "value"); + x.setRequestHeader("Test-header2", "value2"); + + // Test to the end + x.onreadystatechange = function() { + if (x.readyState == XMLHttpRequest.DONE) { + dataOK = (x.responseText == "QML Rocks!\n"); + } + } + + x.send(); + } +} diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/status.expect b/tests/auto/declarative/qdeclarativexmlhttprequest/data/status.expect index 4d940c29c3..cf5830ed0c 100644 --- a/tests/auto/declarative/qdeclarativexmlhttprequest/data/status.expect +++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/status.expect @@ -1,5 +1,5 @@ GET /testdocument.html HTTP/1.1 -ACCEPT-LANGUAGE: en-US +Accept-Language: en-US Connection: Keep-Alive Accept-Encoding: gzip, deflate User-Agent: Mozilla/5.0 diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/tst_qdeclarativexmlhttprequest.cpp b/tests/auto/declarative/qdeclarativexmlhttprequest/tst_qdeclarativexmlhttprequest.cpp index d640840bcd..51b23c732a 100644 --- a/tests/auto/declarative/qdeclarativexmlhttprequest/tst_qdeclarativexmlhttprequest.cpp +++ b/tests/auto/declarative/qdeclarativexmlhttprequest/tst_qdeclarativexmlhttprequest.cpp @@ -74,6 +74,7 @@ private slots: void open_sync(); void open_arg_count(); void setRequestHeader(); + void setRequestHeader_caseInsensitive(); void setRequestHeader_unsent(); void setRequestHeader_illegalName_data(); void setRequestHeader_illegalName(); @@ -368,6 +369,25 @@ void tst_qdeclarativexmlhttprequest::setRequestHeader() delete object; } +// Test valid setRequestHeader() calls with different header cases +void tst_qdeclarativexmlhttprequest::setRequestHeader_caseInsensitive() +{ + TestHTTPServer server(SERVER_PORT); + QVERIFY(server.isValid()); + QVERIFY(server.wait(TEST_FILE("setRequestHeader.expect"), + TEST_FILE("setRequestHeader.reply"), + TEST_FILE("testdocument.html"))); + + QDeclarativeComponent component(&engine, TEST_FILE("setRequestHeader_caseInsensitive.qml")); + QObject *object = component.beginCreate(engine.rootContext()); + QVERIFY(object != 0); + object->setProperty("url", "http://127.0.0.1:14445/testdocument.html"); + component.completeCreate(); + + QTRY_VERIFY(object->property("dataOK").toBool() == true); + + delete object; +} // Test setting headers before open() throws exception void tst_qdeclarativexmlhttprequest::setRequestHeader_unsent() { |