QNetworkReply doesn't finish?
-
I have local FTP server I connect to with Total Commander without a problem. I'm trying to download a single file from it, using QNetworkAccessManager. No error is produced but it's never finished either. This is how I try to do it:
QString surl = QString("ftp://%3/%4").arg(srv, fpath); url = QUrl(surl); url.setPort(port); //21 //evaluates into ftp://192.168.0.102:21/Installer/VER if (url.isValid()) { //qnam is QNetworkAccessManager reply = g->qnam->get(QNetworkRequest(url)); MyFTP::connect(reply.data(), &QNetworkReply::downloadProgress, g, &MyFTP::downloadProgress); MyFTP::connect(reply.data(), &QNetworkReply::readyRead, g, &MyFTP::downloadReadyRead); MyFTP::connect(reply.data(), &QNetworkReply::finished, g, &MyFTP::qnamReply); MyFTP::connect(reply.data(), &QNetworkReply::sslErrors, g, &MyFTP::qnamSslErrors); MyFTP::connect(reply.data(), &QNetworkReply::errorOccurred, g, &MyFTP::qnamError); }
No singnal is ever produced by the QNetworkReply. I made a timer to check on it from time to time and it is stuck on "running" and "not finished" forever.
-
Hi,
Why are you connecting the pointer returned by reply.data rather than the reply itself ?
-
It's QPointer<QNetworkReply> so ::data() returns a pointer. Forgot to mention that.
Also, I made it work by setting user and password in QUrl, not by setting QAuthenticator in response to QNetworkAccessManager::authenticationRequired. So... I don't understand why it didn't work before but now it works.