m_network = networkAccessManager()->get(request);
else if (m_method == QLatin1String("HEAD"))
m_network = networkAccessManager()->head(request);
- else if(m_method == QLatin1String("POST"))
+ else if (m_method == QLatin1String("POST"))
m_network = networkAccessManager()->post(request, m_data);
- else if(m_method == QLatin1String("PUT"))
+ else if (m_method == QLatin1String("PUT"))
m_network = networkAccessManager()->put(request, m_data);
+ else if (m_method == QLatin1String("DELETE"))
+ m_network = networkAccessManager()->deleteResource(request);
QObject::connect(m_network, SIGNAL(downloadProgress(qint64,qint64)),
this, SLOT(downloadProgress(qint64)));
if (method != QLatin1String("GET") &&
method != QLatin1String("PUT") &&
method != QLatin1String("HEAD") &&
- method != QLatin1String("POST"))
+ method != QLatin1String("POST") &&
+ method != QLatin1String("DELETE"))
THROW_DOM(SYNTAX_ERR, "Unsupported HTTP method type");
// Test to the end
x.onreadystatechange = function() {
if (x.readyState == XMLHttpRequest.DONE) {
- if (reqType == "HEAD")
+ if (reqType == "HEAD" || reqType == "DELETE")
dataOK = (x.responseText == "");
else
dataOK = (x.responseText == "QML Rocks!\n");
-HEAD /testdocument.html HTTP/1.1
+DELETE /testdocument.html HTTP/1.1
ACCEPT-LANGUAGE: en-US
Connection: Keep-Alive
Accept-Encoding: gzip
delete object;
}
-// Test that send for a GET or HEAD ignores data
+// Test that sends for GET, HEAD and DELETE ignore data
void tst_qdeclarativexmlhttprequest::send_ignoreData()
{
{
{
TestHTTPServer server(SERVER_PORT);
QVERIFY(server.isValid());
- QVERIFY(server.wait(TEST_FILE("send_ignoreData_PUT.expect"),
+ QVERIFY(server.wait(TEST_FILE("send_ignoreData_HEAD.expect"),
TEST_FILE("send_ignoreData.reply"),
QUrl()));
delete object;
}
+
+ {
+ TestHTTPServer server(SERVER_PORT);
+ QVERIFY(server.isValid());
+ QVERIFY(server.wait(TEST_FILE("send_ignoreData_DELETE.expect"),
+ TEST_FILE("send_ignoreData.reply"),
+ QUrl()));
+
+ QDeclarativeComponent component(&engine, TEST_FILE("send_ignoreData.qml"));
+ QObject *object = component.beginCreate(engine.rootContext());
+ QVERIFY(object != 0);
+ object->setProperty("reqType", "DELETE");
+ object->setProperty("url", "http://127.0.0.1:14445/testdocument.html");
+ component.completeCreate();
+
+ QTRY_VERIFY(object->property("dataOK").toBool() == true);
+
+ delete object;
+ }
}
// Test that send()'ing data works