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>
This commit is contained in:
parent
44e58a337a
commit
14496b18a6
|
@ -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();
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
}
|
|
@ -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
|
||||
|
|
|
@ -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()
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue