summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPetr Mrázek <peterix@gmail.com>2014-12-12 00:44:55 +0100
committerPetr Mrázek <peterix@gmail.com>2014-12-12 00:44:55 +0100
commitbbcd44a65784a1d775c4192b407b208c99520f23 (patch)
treec5153bf886f2fd0471f42c4eee48f13e4193b8a7
parenta060d79c123e98baad8f1ea48600bd7449c9c66a (diff)
downloadMultiMC-bbcd44a65784a1d775c4192b407b208c99520f23.tar
MultiMC-bbcd44a65784a1d775c4192b407b208c99520f23.tar.gz
MultiMC-bbcd44a65784a1d775c4192b407b208c99520f23.tar.lz
MultiMC-bbcd44a65784a1d775c4192b407b208c99520f23.tar.xz
MultiMC-bbcd44a65784a1d775c4192b407b208c99520f23.zip
NOISSUE Always follow redirects for NetAction based downloads
-rw-r--r--gui/MainWindow.cpp1
-rw-r--r--gui/pages/LegacyJarModPage.cpp1
-rw-r--r--logic/net/ByteArrayDownload.cpp39
-rw-r--r--logic/net/ByteArrayDownload.h2
-rw-r--r--logic/net/CacheDownload.cpp39
-rw-r--r--logic/net/CacheDownload.h2
6 files changed, 36 insertions, 48 deletions
diff --git a/gui/MainWindow.cpp b/gui/MainWindow.cpp
index 0958be8c..43e8b6c0 100644
--- a/gui/MainWindow.cpp
+++ b/gui/MainWindow.cpp
@@ -286,7 +286,6 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWi
auto meta = MMC->metacache()->resolveEntry("skins", profile.name + ".png");
auto action = CacheDownload::make(
QUrl("http://" + URLConstants::SKINS_BASE + profile.name + ".png"), meta);
- action->m_followRedirects = true;
skin_dls.append(action);
meta->stale = true;
}
diff --git a/gui/pages/LegacyJarModPage.cpp b/gui/pages/LegacyJarModPage.cpp
index 0d480d80..023ebb2a 100644
--- a/gui/pages/LegacyJarModPage.cpp
+++ b/gui/pages/LegacyJarModPage.cpp
@@ -114,7 +114,6 @@ void LegacyJarModPage::on_addForgeBtn_clicked()
{
NetJob *fjob = new NetJob("Forge download");
auto cacheDl = CacheDownload::make(forge->universal_url, entry);
- cacheDl->m_followRedirects = true;
fjob->addNetAction(cacheDl);
ProgressDialog dlg(this);
dlg.exec(fjob);
diff --git a/logic/net/ByteArrayDownload.cpp b/logic/net/ByteArrayDownload.cpp
index d51240cc..b6bbbd7f 100644
--- a/logic/net/ByteArrayDownload.cpp
+++ b/logic/net/ByteArrayDownload.cpp
@@ -58,28 +58,25 @@ void ByteArrayDownload::downloadError(QNetworkReply::NetworkError error)
void ByteArrayDownload::downloadFinished()
{
- if (m_followRedirects)
+ QVariant redirect = m_reply->header(QNetworkRequest::LocationHeader);
+ QString redirectURL;
+ if(redirect.isValid())
{
- 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;
- }
+ 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
diff --git a/logic/net/ByteArrayDownload.h b/logic/net/ByteArrayDownload.h
index a1c82478..691f32ae 100644
--- a/logic/net/ByteArrayDownload.h
+++ b/logic/net/ByteArrayDownload.h
@@ -33,8 +33,6 @@ public:
QString m_errorString;
- bool m_followRedirects = false;
-
public
slots:
virtual void start();
diff --git a/logic/net/CacheDownload.cpp b/logic/net/CacheDownload.cpp
index 23214a98..b2fa4a12 100644
--- a/logic/net/CacheDownload.cpp
+++ b/logic/net/CacheDownload.cpp
@@ -101,28 +101,25 @@ void CacheDownload::downloadError(QNetworkReply::NetworkError error)
}
void CacheDownload::downloadFinished()
{
- if (m_followRedirects)
+ QVariant redirect = m_reply->header(QNetworkRequest::LocationHeader);
+ QString redirectURL;
+ if(redirect.isValid())
{
- 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;
- }
+ 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
diff --git a/logic/net/CacheDownload.h b/logic/net/CacheDownload.h
index 0dbbef4c..07b6701d 100644
--- a/logic/net/CacheDownload.h
+++ b/logic/net/CacheDownload.h
@@ -36,8 +36,6 @@ private:
bool wroteAnyData = false;
public:
- bool m_followRedirects = false;
-
explicit CacheDownload(QUrl url, MetaEntryPtr entry);
static CacheDownloadPtr make(QUrl url, MetaEntryPtr entry)
{