diff options
author | Shane Kearns <ext-shane.2.kearns@nokia.com> | 2012-04-25 14:53:23 (GMT) |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-05-08 23:13:59 (GMT) |
commit | 64ba8012c54a49d371cca21d3c296c01cbbb0278 (patch) | |
tree | 54b6d01aec3d10766062af79eaf6bb14058cc658 /src/network | |
parent | 12f5d32f89eb313d0b8b3bc426c2a9367d8c2664 (diff) | |
download | Qt-64ba8012c54a49d371cca21d3c296c01cbbb0278.zip Qt-64ba8012c54a49d371cca21d3c296c01cbbb0278.tar.gz Qt-64ba8012c54a49d371cca21d3c296c01cbbb0278.tar.bz2 |
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>
(cherry picked from commit a5fcd3f799371239dd375150648bf77cb4745626)
Diffstat (limited to 'src/network')
-rw-r--r-- | src/network/access/qftp.cpp | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/src/network/access/qftp.cpp b/src/network/access/qftp.cpp index 0fd34b2..b23b373 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; @@ -863,14 +863,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() |