Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-25494

FTP download do not abort when calling the abort method of QNetworkReply.

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P2: Important
    • 4.8.x, 5.0.0
    • 4.8.1
    • Network
    • None
    • Tested on Ubuntu 11.10 Oneiric with QT 4.7.1 and Mac OS X 10.6 Snow Leopard with QT 4.8.1.

    Description

      When using QNetworkAccessManager to download a file from HTTP everything works.
      But when using it for downloading a file from FTP, you cannot abort the download completely.
      In this case all signals from QNetworkReply will be emit correctly, but in the background it is still downloading.

      Abort.h
      #ifndef ABORT_H_
      #define ABORT_H_
      
      #include <QDebug>
      #include <QNetworkReply>
      #include <QObject>
      
      class Abort : public QObject
      {
      	Q_OBJECT
      
      private:
      	QNetworkReply *_reply;
      
      public:
      	Abort( QNetworkReply *reply ) :
      		_reply( reply )
      	{}
      
      	virtual ~Abort()
      	{}
      
      public slots:
      	void abort()
      	{
      		if ( _reply )
      		{
      			qDebug() << "Calling abort!";
      			_reply->abort();
      		}
      	}
      };
      
      #endif /* ABORT_H_ */
      
      TestFtpAbort.cpp
      #include <QNetworkAccessManager>
      #include <QTimer>
      #include <QEventLoop>
      #include <QUrl>
      #include <QCoreApplication>
      
      #include "Abort.h"
      
      int main(int argc, char *argv[])
      {
      	QCoreApplication app(argc, argv);
      	QNetworkAccessManager man;
      
      	QString file = "ftp://ftp.qt.nokia.com/qt/source/qt-everywhere-opensource-src-4.8.1.zip";
      //	QString file = "http://get.qt.nokia.com/qt/source/qt-everywhere-opensource-src-4.8.1.zip";
      
      	QNetworkReply *reply = man.get( QNetworkRequest( QUrl( file ) ) );
      	Abort abort( reply );
      
      	QTimer::singleShot( 5000, &abort, SLOT( abort() ) );
      
      	return app.exec();
      }
      

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            shkearns Shane Kearns
            dape82 Daniel Pecar
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes