[Interest] Can't download file with QNetworkAccessManager: "connection closed"

Nikos Chantziaras realnc at gmail.com
Sun Jun 8 01:49:53 CEST 2014


I have a weird problem. I am unable to download a file from a specific 
server (ran by sourceforge) using QNetworkAccessManager and 
QNetworkRequest. Example:


   this->fNetManager = new QNetworkAccessManager(this);
   connect(this->fNetManager, SIGNAL(finished(QNetworkReply*)),
           SLOT(fReplyFinished(QNetworkReply*)));

   QNetworkRequest request(QUrl("http://qtads.sf.net/COPYING"));

   this->fReply = this->fNetManager->get(request);
   connect(this->fReply, SIGNAL(error(QNetworkReply::NetworkError)),
           SLOT(fErrorOccurred(QNetworkReply::NetworkError)));


The fReplyFinished() slot:


   void Foo::fReplyFinished(QNetworkReply* reply)
   {
       if (reply->error() != QNetworkReply::NoError) {
           qDebug() << this->fReply->errorString()l
           return;
       }
   }


This result in:

   Connection closed

being printed. It's impossible to download the file. If I use another 
server (something not hosted by SourceForge), all is fine.

Using wget:

   wget http://qtads.sf.net/COPYING

works just fine. Using a simple Python program:

   import urllib2
   response = urllib2.urlopen('http://qtads.sf.net/COPYING')
   html = response.read()

also works just fine. The only one not able to fetch the file, is Qt. 
Any ideas on why this fails?

I'm on Qt 4.8.5, on Gentoo Linux AMD64.




More information about the Interest mailing list