aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCharles Yin <charles.yin@nokia.com>2011-07-27 09:57:37 +1000
committerQt by Nokia <qt-info@nokia.com>2011-07-28 07:12:34 +0200
commit14496b18a67982ee25ed43aed6b6bcd7d6fa23ee (patch)
treec52c7ab1639a691308da90e3e628d31e14559186
parent44e58a337a9c314d4542ee6f2acc571aba877ccb (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>
-rw-r--r--src/declarative/qml/qdeclarativexmlhttprequest.cpp2
-rw-r--r--tests/auto/declarative/qdeclarativexmlhttprequest/data/abort.expect2
-rw-r--r--tests/auto/declarative/qdeclarativexmlhttprequest/data/getResponseHeader.expect2
-rw-r--r--tests/auto/declarative/qdeclarativexmlhttprequest/data/open_network.expect2
-rw-r--r--tests/auto/declarative/qdeclarativexmlhttprequest/data/send_data.1.expect2
-rw-r--r--tests/auto/declarative/qdeclarativexmlhttprequest/data/send_data.4.expect2
-rw-r--r--tests/auto/declarative/qdeclarativexmlhttprequest/data/send_data.6.expect2
-rw-r--r--tests/auto/declarative/qdeclarativexmlhttprequest/data/send_ignoreData_DELETE.expect2
-rw-r--r--tests/auto/declarative/qdeclarativexmlhttprequest/data/send_ignoreData_GET.expect2
-rw-r--r--tests/auto/declarative/qdeclarativexmlhttprequest/data/send_ignoreData_HEAD.expect2
-rw-r--r--tests/auto/declarative/qdeclarativexmlhttprequest/data/setRequestHeader.expect6
-rw-r--r--tests/auto/declarative/qdeclarativexmlhttprequest/data/setRequestHeader_caseInsensitive.qml30
-rw-r--r--tests/auto/declarative/qdeclarativexmlhttprequest/data/status.expect2
-rw-r--r--tests/auto/declarative/qdeclarativexmlhttprequest/tst_qdeclarativexmlhttprequest.cpp20
14 files changed, 64 insertions, 14 deletions
diff --git a/src/declarative/qml/qdeclarativexmlhttprequest.cpp b/src/declarative/qml/qdeclarativexmlhttprequest.cpp
index 5a7aa0a003..194a60f2d3 100644
--- a/src/declarative/qml/qdeclarativexmlhttprequest.cpp
+++ b/src/declarative/qml/qdeclarativexmlhttprequest.cpp
@@ -1601,7 +1601,7 @@ static v8::Handle<v8::Value> qmlxmlhttprequest_setRequestHeader(const v8::Argume
nameUpper.startsWith(QLatin1String("SEC-")))
return v8::Undefined();
- r->addHeader(nameUpper, value);
+ r->addHeader(name, value);
return v8::Undefined();
}
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()
{