From 0c2e2094ee96ebe8764dd977bd0b5eb254579dcc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Mr=C3=A1zek?= Date: Mon, 22 Jan 2018 03:09:00 +0100 Subject: NOISSUE clean up download redirects and handle their errors as fatal --- api/logic/net/Download.cpp | 33 ++++++++++----------------------- 1 file changed, 10 insertions(+), 23 deletions(-) (limited to 'api/logic/net/Download.cpp') diff --git a/api/logic/net/Download.cpp b/api/logic/net/Download.cpp index e45c41cb..97f5401e 100644 --- a/api/logic/net/Download.cpp +++ b/api/logic/net/Download.cpp @@ -181,6 +181,12 @@ bool Download::handleRedirect() * FIXME: report Qt bug for this */ redirect = QUrl(redirectStr, QUrl::TolerantMode); + if(!redirect.isValid()) + { + qWarning() << "Failed to parse redirect URL:" << redirectStr; + downloadError(QNetworkReply::ProtocolFailure); + return false; + } qDebug() << "Fixed location header:" << redirect; } else @@ -188,29 +194,10 @@ bool Download::handleRedirect() qDebug() << "Location header:" << redirect; } - QString redirectURL; - if(redirect.isValid()) - { - redirectURL = redirect.toString(); - } - // FIXME: This is a hack for - else if(m_reply->hasRawHeader("Location")) - { - auto data = m_reply->rawHeader("Location"); - if(data.size() > 2 && data[0] == '/' && data[1] == '/') - { - redirectURL = m_reply->url().scheme() + ":" + data; - } - } - - if (!redirectURL.isEmpty()) - { - m_url = QUrl(redirect.toString()); - qDebug() << "Following redirect to " << m_url.toString(); - start(); - return true; - } - return false; + m_url = QUrl(redirect.toString()); + qDebug() << "Following redirect to " << m_url.toString(); + start(); + return true; } -- cgit v1.2.3