summaryrefslogtreecommitdiffstats
path: root/tests/auto
diff options
context:
space:
mode:
authorMatt Broadstone <mbroadstone@devonit.com>2014-08-18 21:02:52 (GMT)
committerMatt Broadstone <mbroadst@gmail.com>2014-08-18 21:48:44 (GMT)
commitc830cfab4f9b264c26c0111fe923562b82f72fed (patch)
tree6c41a9eca622f831a98d50b299ebe484cf87a1d3 /tests/auto
parent469dcfff3e39249b0a5eb98242fbe5f917587246 (diff)
downloadQt-c830cfab4f9b264c26c0111fe923562b82f72fed.zip
Qt-c830cfab4f9b264c26c0111fe923562b82f72fed.tar.gz
Qt-c830cfab4f9b264c26c0111fe923562b82f72fed.tar.bz2
refactor disconnectFromFtp to remove cached entries when necessary
In cases where a cached ftp connection fails to connect, or a file transfer has failed, we should removed the cached connection. Since qnam has an idea of a single internal QFtp per full operation, when file transfers failed previously the cached connection would be reused for subsequent connections and thus fail. [ChangeLog][QtNetwork][QNetworkAccessManager] QNetworkAccessManager now properly handles FTP transfer failures by removing failed cached ftp connections. Task-number: QTBUG-40797 (cherry picked and adapted from qtbase/45cbbe56bc13216b83215ea148590eccf81f420a) Change-Id: Ie9eec5ec54af16a8d19e34d04bdd993cc7bbd0f5 Reviewed-by: Richard J. Moore <rich@kde.org>
Diffstat (limited to 'tests/auto')
-rw-r--r--tests/auto/qnetworkreply/tst_qnetworkreply.cpp27
1 files changed, 27 insertions, 0 deletions
diff --git a/tests/auto/qnetworkreply/tst_qnetworkreply.cpp b/tests/auto/qnetworkreply/tst_qnetworkreply.cpp
index 5e295cb..ddf4b17 100644
--- a/tests/auto/qnetworkreply/tst_qnetworkreply.cpp
+++ b/tests/auto/qnetworkreply/tst_qnetworkreply.cpp
@@ -194,6 +194,7 @@ private Q_SLOTS:
void getFromFileSpecial();
void getFromFtp_data();
void getFromFtp();
+ void getFromFtpAfterError(); // QTBUG-40797
void getFromHttp_data();
void getFromHttp();
void getErrors_data();
@@ -1598,6 +1599,32 @@ void tst_QNetworkReply::getFromFtp()
QCOMPARE(reply->readAll(), reference.readAll());
}
+void tst_QNetworkReply::getFromFtpAfterError()
+{
+ QNetworkRequest invalidRequest(QUrl("ftp://" + QtNetworkSettings::serverName() + "/qtest/invalid.txt"));
+ QNetworkReplyPtr invalidReply;
+ invalidReply = manager.get(invalidRequest);
+ QSignalSpy spy(invalidReply.data(), SIGNAL(error(QNetworkReply::NetworkError)));
+
+ // now run the request:
+ connect(invalidReply.data(), SIGNAL(error(QNetworkReply::NetworkError)),
+ &QTestEventLoop::instance(), SLOT(exitLoop()));
+ QTestEventLoop::instance().enterLoop(5);
+ QVERIFY(!QTestEventLoop::instance().timeout());
+ QVERIFY(!spy.isEmpty());
+ QCOMPARE(invalidReply->error(), QNetworkReply::ContentNotFoundError);
+
+ QFile reference("srcdir:/rfc3252.txt");
+ QVERIFY(reference.open(QIODevice::ReadOnly));
+ QNetworkRequest validRequest(QUrl("ftp://" + QtNetworkSettings::serverName() + "/qtest/rfc3252.txt"));
+ QNetworkReplyPtr validReply;
+ RUN_REQUEST(runSimpleRequest(QNetworkAccessManager::GetOperation, validRequest, validReply));
+ QCOMPARE(validReply->url(), validRequest.url());
+ QCOMPARE(validReply->error(), QNetworkReply::NoError);
+ QCOMPARE(validReply->header(QNetworkRequest::ContentLengthHeader).toLongLong(), reference.size());
+ QCOMPARE(validReply->readAll(), reference.readAll());
+}
+
void tst_QNetworkReply::getFromHttp_data()
{
QTest::addColumn<QString>("referenceName");