summaryrefslogtreecommitdiffstats
path: root/tests/auto/qhttpnetworkconnection
diff options
context:
space:
mode:
authorMarkus Goetz <Markus.Goetz@nokia.com>2010-04-21 08:28:31 (GMT)
committerMarkus Goetz <Markus.Goetz@nokia.com>2010-04-21 08:29:42 (GMT)
commit6c69440513ba9227edc47b6914190434b07ff973 (patch)
treedc06c0cd22574373685722ee0f84f05e4d8211ce /tests/auto/qhttpnetworkconnection
parentc39365020425d9ec80759418d7ac45b0208cb159 (diff)
downloadQt-6c69440513ba9227edc47b6914190434b07ff973.zip
Qt-6c69440513ba9227edc47b6914190434b07ff973.tar.gz
Qt-6c69440513ba9227edc47b6914190434b07ff973.tar.bz2
QNAM HTTP: Fixed a bug when getting empty files with pipelining
Instead of returning from the socket's readyRead() handler break out of the switch() and continue parsing the data.
Diffstat (limited to 'tests/auto/qhttpnetworkconnection')
-rw-r--r--tests/auto/qhttpnetworkconnection/tst_qhttpnetworkconnection.cpp49
1 files changed, 49 insertions, 0 deletions
diff --git a/tests/auto/qhttpnetworkconnection/tst_qhttpnetworkconnection.cpp b/tests/auto/qhttpnetworkconnection/tst_qhttpnetworkconnection.cpp
index 0b55390..21f228a 100644
--- a/tests/auto/qhttpnetworkconnection/tst_qhttpnetworkconnection.cpp
+++ b/tests/auto/qhttpnetworkconnection/tst_qhttpnetworkconnection.cpp
@@ -107,6 +107,8 @@ private Q_SLOTS:
void getMultiple();
void getMultipleWithPipeliningAndMultiplePriorities();
void getMultipleWithPriorities();
+
+ void getEmptyWithPipelining();
};
tst_QHttpNetworkConnection::tst_QHttpNetworkConnection()
@@ -985,6 +987,53 @@ void tst_QHttpNetworkConnection::getMultipleWithPriorities()
}
+class GetEmptyWithPipeliningReceiver : public QObject
+{
+ Q_OBJECT
+public:
+ int receivedCount;
+ int requestCount;
+ GetEmptyWithPipeliningReceiver(int rq) : receivedCount(0),requestCount(rq) { }
+public Q_SLOTS:
+ void finishedSlot() {
+ QHttpNetworkReply *reply = (QHttpNetworkReply*) sender();
+ receivedCount++;
+
+ if (receivedCount == requestCount)
+ QTestEventLoop::instance().exitLoop();
+ }
+};
+
+void tst_QHttpNetworkConnection::getEmptyWithPipelining()
+{
+ quint16 requestCount = 50;
+ // use 2 connections.
+ QHttpNetworkConnection connection(2, QtNetworkSettings::serverName());
+ GetEmptyWithPipeliningReceiver receiver(requestCount);
+
+ QUrl url("http://" + QtNetworkSettings::serverName() + "/cgi-bin/echo.cgi"); // a get on this = getting an empty file
+ QList<QHttpNetworkRequest*> requests;
+ QList<QHttpNetworkReply*> replies;
+
+ for (int i = 0; i < requestCount; i++) {
+ QHttpNetworkRequest *request = 0;
+ request = new QHttpNetworkRequest(url, QHttpNetworkRequest::Get);
+ request->setPipeliningAllowed(true);
+
+ requests.append(request);
+ QHttpNetworkReply *reply = connection.sendRequest(*request);
+ connect(reply, SIGNAL(finished()), &receiver, SLOT(finishedSlot()));
+ replies.append(reply);
+ }
+
+ QTestEventLoop::instance().enterLoop(20);
+ QVERIFY(!QTestEventLoop::instance().timeout());
+
+ qDeleteAll(requests);
+ qDeleteAll(replies);
+}
+
+
QTEST_MAIN(tst_QHttpNetworkConnection)
#include "tst_qhttpnetworkconnection.moc"