summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorShane Kearns <ext-shane.2.kearns@nokia.com>2012-04-25 15:53:23 +0100
committerQt by Nokia <qt-info@nokia.com>2012-05-03 06:10:02 +0200
commita5fcd3f799371239dd375150648bf77cb4745626 (patch)
tree7ce9a70142a1f333fd6e67ea5d97726b3a6a5c23
parentc6864e0a580793f29c7d2cf180fc0f2ac2fc2b2c (diff)
QFtp - implement fast abort for downloads
Most FTP servers do not support the ABOR command (they don't process control channel traffic until the data channel is finished). Or they require the telnet IP & sync procedure on the control channel (this requires sending TCP urgent data, which we do not support). Following behaviour of most browsers and GUI FTP clients, abort downloads by resetting the data channel. Abort of uploads needs no change, because the client closes the data channel rather than the server. Task-number: QTBUG-25494 Change-Id: I69e7b7c04d709d26def9a4a7081074e1cbf69701 Reviewed-by: Martin Petersson <Martin.Petersson@nokia.com>
-rw-r--r--src/network/access/qftp.cpp21
1 files changed, 16 insertions, 5 deletions
diff --git a/src/network/access/qftp.cpp b/src/network/access/qftp.cpp
index c7ad810084..a50415715c 100644
--- a/src/network/access/qftp.cpp
+++ b/src/network/access/qftp.cpp
@@ -665,7 +665,7 @@ void QFtpDTP::socketReadyRead()
return;
}
- if (pi->abortState == QFtpPI::AbortStarted) {
+ if (pi->abortState != QFtpPI::None) {
// discard data
socket->readAll();
return;
@@ -865,14 +865,25 @@ void QFtpPI::abort()
// ABOR already sent
return;
- abortState = AbortStarted;
+ if (currentCmd.isEmpty())
+ return; //no command in progress
+
+ if (currentCmd.startsWith(QLatin1String("STOR "))) {
+ abortState = AbortStarted;
#if defined(QFTPPI_DEBUG)
- qDebug("QFtpPI send: ABOR");
+ qDebug("QFtpPI send: ABOR");
#endif
- commandSocket.write("ABOR\r\n", 6);
+ commandSocket.write("ABOR\r\n", 6);
- if (currentCmd.startsWith(QLatin1String("STOR ")))
dtp.abortConnection();
+ } else {
+ //Deviation from RFC 959:
+ //Most FTP servers do not support ABOR, or require the telnet
+ //IP & synch sequence (TCP urgent data) which is not supported by QTcpSocket.
+ //Following what most FTP clients do, just reset the data connection and wait for 426
+ abortState = WaitForAbortToFinish;
+ dtp.abortConnection();
+ }
}
void QFtpPI::hostFound()