I’m writing a C++ application using Qt framework that needs to download a file from SourceForge.
I have to download this file https://sourceforge.net/projects/meshlab/files/updates/1.3.3/updates.xml
I wrote the following code using Qt and the QHttp class:
QFile tmpfile;
int hostreqid;
int checkreqid;
...
...
tmpfile.setFileName("updates.xml");
hostreqid = http.setHost("sourceforge.net",QHttp::ConnectionModeHttp);
checkreqid = http.get(QString(QUrl::toPercentEncoding("/projects/meshlab/files/updates/1.3.3/updates.xml")),&tmpfile);
...
...
void parseAnswer( int id,bool error )
{
if (!error && (id == checkreqid))
{
...
tmpfile.close();
}
if (error)
{
QHttp::Error err = http.error();
QString errstrg = http.errorString();
}
}
Both QHttp::setHost and QHttp::get are not blocking functions returning immediately an int id. When the http file transfer completed the parseAnswer function is automatically called.
The problem is that inside the updates.xml file I got, instead the data I was expecting I received an html file from SouceForge reporting an “Invalid Project” error.
I noticed that when I access the https://sourceforge.net/projects/meshlab/files/updates/1.3.3/updates.xml from browser I have been redirected to https://sourceforge.net/projects/meshlab/files/updates/1.3.3/updates.xml/download page. I tried also this other address but nothing changed.
Please, notice that I’m using Http protocol (QHttp::ConnectionModeHttp) instead of the https. If I could I would wish to avoid to use the https. Can be the source of the problem?
Thanks a lot!
I got the answer in another forum (thanks to AcerExtensa…I don’t know his real name). Looks like the problem was that I missed to handle the sourceforge redirection.
I posted here his reply:
Thanks a lot to the ones who tried to help me!