summaryrefslogtreecommitdiffstats
path: root/api
diff options
context:
space:
mode:
authorPetr Mrázek <peterix@gmail.com>2018-01-22 03:09:00 +0100
committerPetr Mrázek <peterix@gmail.com>2018-01-22 03:09:00 +0100
commit0c2e2094ee96ebe8764dd977bd0b5eb254579dcc (patch)
tree90906b22226c1308f23b1744c20f3014a9d36f15 /api
parentc33b4e252f8bf37bc716adc7789926185c3e384c (diff)
downloadMultiMC-0c2e2094ee96ebe8764dd977bd0b5eb254579dcc.tar
MultiMC-0c2e2094ee96ebe8764dd977bd0b5eb254579dcc.tar.gz
MultiMC-0c2e2094ee96ebe8764dd977bd0b5eb254579dcc.tar.lz
MultiMC-0c2e2094ee96ebe8764dd977bd0b5eb254579dcc.tar.xz
MultiMC-0c2e2094ee96ebe8764dd977bd0b5eb254579dcc.zip
NOISSUE clean up download redirects and handle their errors as fatal
Diffstat (limited to 'api')
-rw-r--r--api/logic/net/Download.cpp33
1 files changed, 10 insertions, 23 deletions
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;
}