From ec6d7694f72498d1b156bb0ae8d305e01931f7b2 Mon Sep 17 00:00:00 2001 From: Peter Hartmann Date: Mon, 14 Nov 2011 16:21:38 +0100 Subject: HTTP: blacklist server for pipelining that server was found out not to support HTTP pipelining. tested manually; for more information see the task. Reviewed-by: Markus Goetz Task-number: QTBUG-21369 --- src/network/access/qhttpnetworkconnectionchannel.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/network/access/qhttpnetworkconnectionchannel.cpp b/src/network/access/qhttpnetworkconnectionchannel.cpp index 15fda34..b9db7fe 100644 --- a/src/network/access/qhttpnetworkconnectionchannel.cpp +++ b/src/network/access/qhttpnetworkconnectionchannel.cpp @@ -788,6 +788,7 @@ void QHttpNetworkConnectionChannel::detectPipeliningSupport() && (!serverHeaderField.contains("Netscape-Enterprise/3.")) // this is adpoted from the knowledge of the Nokia 7.x browser team (DEF143319) && (!serverHeaderField.contains("WebLogic")) + && (!serverHeaderField.startsWith("Rocket")) // a Python Web Server, see Web2py.com ) { pipeliningSupported = QHttpNetworkConnectionChannel::PipeliningProbablySupported; } else { -- cgit v0.12 From a32bfdef6d6b45c916f143dcf8495a2e102c3eec Mon Sep 17 00:00:00 2001 From: Peter Hartmann Date: Mon, 14 Nov 2011 17:11:00 +0100 Subject: network auto tests: add QNetworkReply test for pipelining Reviewed-by: Markus Goetz Task-number: QTBUG-21369 --- tests/auto/qnetworkreply/tst_qnetworkreply.cpp | 39 ++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/tests/auto/qnetworkreply/tst_qnetworkreply.cpp b/tests/auto/qnetworkreply/tst_qnetworkreply.cpp index 14ad6a9..371ac57 100644 --- a/tests/auto/qnetworkreply/tst_qnetworkreply.cpp +++ b/tests/auto/qnetworkreply/tst_qnetworkreply.cpp @@ -168,6 +168,7 @@ public Q_SLOTS: void gotError(); void authenticationRequired(QNetworkReply*,QAuthenticator*); void proxyAuthenticationRequired(const QNetworkProxy &,QAuthenticator*); + void pipeliningHelperSlot(); #ifndef QT_NO_OPENSSL void sslErrors(QNetworkReply*,const QList &); @@ -380,6 +381,7 @@ private Q_SLOTS: void dontInsertPartialContentIntoTheCache(); void synchronousAuthenticationCache(); + void pipelining(); // NOTE: This test must be last! void parentingRepliesToTheApp(); @@ -6446,6 +6448,43 @@ void tst_QNetworkReply::synchronousAuthenticationCache() } } +void tst_QNetworkReply::pipelining() +{ + QString urlString("http://" + QtNetworkSettings::serverName() + "/qtest/cgi-bin/echo.cgi?"); + QList replies; + for (int a = 0; a < 20; a++) { + QNetworkRequest request(urlString + QString::number(a)); + request.setAttribute(QNetworkRequest::HttpPipeliningAllowedAttribute, QVariant(true)); + replies.append(manager.get(request)); + connect(replies.at(a), SIGNAL(finished()), this, SLOT(pipeliningHelperSlot())); + } + QTestEventLoop::instance().enterLoop(20); + QVERIFY(!QTestEventLoop::instance().timeout()); +} + +void tst_QNetworkReply::pipeliningHelperSlot() { + static int a = 0; + + // check that pipelining was used in at least one of the replies + static bool pipeliningWasUsed = false; + QNetworkReply *reply = qobject_cast(sender()); + bool pipeliningWasUsedInReply = reply->attribute(QNetworkRequest::HttpPipeliningWasUsedAttribute).toBool(); + if (pipeliningWasUsedInReply) + pipeliningWasUsed = true; + + // check that the contents match (the response to echo.cgi?3 should return 3 etc.) + QString urlQueryString = reply->url().queryItems().at(0).first; + QString content = reply->readAll(); + QVERIFY2(urlQueryString == content, "data corruption with pipelining detected"); + + a++; + + if (a == 20) { // all replies have finished + QTestEventLoop::instance().exitLoop(); + QVERIFY2(pipeliningWasUsed, "pipelining was not used in any of the replies when trying to test pipelining"); + } +} + // NOTE: This test must be last testcase in tst_qnetworkreply! void tst_QNetworkReply::parentingRepliesToTheApp() { -- cgit v0.12