From 20cb97a35af5097e9d3b2062c0dfcb5f2e5fff5c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Mr=C3=A1zek?= Date: Sat, 6 Sep 2014 18:16:56 +0200 Subject: Sync from quickmods --- logic/net/CacheDownload.cpp | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'logic/net/CacheDownload.cpp') diff --git a/logic/net/CacheDownload.cpp b/logic/net/CacheDownload.cpp index d2a9bdee..6d937e30 100644 --- a/logic/net/CacheDownload.cpp +++ b/logic/net/CacheDownload.cpp @@ -101,6 +101,30 @@ void CacheDownload::downloadError(QNetworkReply::NetworkError error) } void CacheDownload::downloadFinished() { + if (m_followRedirects) + { + QVariant redirect = m_reply->header(QNetworkRequest::LocationHeader); + QString redirectURL; + if(redirect.isValid()) + { + redirectURL = redirect.toString(); + } + // FIXME: This is a hack for https://bugreports.qt-project.org/browse/QTBUG-41061 + 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()); + QLOG_INFO() << "Following redirect to " << m_url.toString(); + start(); + return; + } + } + // if the download succeeded if (m_status == Job_Failed) { -- cgit v1.2.3