pypt / fervor

Simple multiplatform (Qt-based) application update tool inspired by Sparkle
MIT License
213 stars 72 forks source link

Problem getting Xml file with Qt5.1 from redirected sites #17

Closed HollyPony closed 10 years ago

HollyPony commented 10 years ago

Hi, I tried to use your updater with a redirected XML file hosted by Sourceforge (cf: http://sourceforge.net/projects/serizer/files/Serizer.xml/download).

EDIT : The error is "Connection closed"

I'm using Qt5.1 on OSX Mavericks (the last) with clang64. I resolve it by settings a UserAgent in request header, I really don't know why but it work like a charm now !

I guess the same fix must be apply to executable downloader function.

I suggest a fix for this problem, set the content-type mime type header is not mandatory but I think it's a better way to using protocol:

diff --git a/fvupdater.cpp b/fvupdater.cpp
index 2e5a429..a958204 100644
--- a/fvupdater.cpp
+++ b/fvupdater.cpp
@@ -289,7 +289,12 @@ void FvUpdater::startDownloadFeed(QUrl url)
{
    m_xml.clear();

-       m_reply = m_qnam.get(QNetworkRequest(url));
+    QNetworkRequest request;
+    request.setHeader(QNetworkRequest::ContentTypeHeader, "application/xml");
+    request.setHeader(QNetworkRequest::UserAgentHeader, QApplication::applicationName());
+    request.setUrl(url);
+
+    m_reply = m_qnam.get(request);

        connect(m_reply, SIGNAL(readyRead()), this, SLOT(httpFeedReadyRead()));
        connect(m_reply, SIGNAL(downloadProgress(qint64, qint64)), this, SLOT(httpFeedUpdateDataReadProgress(qint64, qint64)));
pypt commented 10 years ago

Thanks, Liomka! I've pushed the change.