summaryrefslogtreecommitdiffstats
path: root/logic/net/ByteArrayDownload.cpp
diff options
context:
space:
mode:
authorPetr Mrázek <peterix@gmail.com>2014-09-06 18:16:56 +0200
committerPetr Mrázek <peterix@gmail.com>2014-09-06 19:03:05 +0200
commit20cb97a35af5097e9d3b2062c0dfcb5f2e5fff5c (patch)
tree56bf51e681f2e73590a549499bd83d7b505c39f8 /logic/net/ByteArrayDownload.cpp
parent36efcf8d3c0cbd7823fc65569cfc2b011435db2c (diff)
downloadMultiMC-20cb97a35af5097e9d3b2062c0dfcb5f2e5fff5c.tar
MultiMC-20cb97a35af5097e9d3b2062c0dfcb5f2e5fff5c.tar.gz
MultiMC-20cb97a35af5097e9d3b2062c0dfcb5f2e5fff5c.tar.lz
MultiMC-20cb97a35af5097e9d3b2062c0dfcb5f2e5fff5c.tar.xz
MultiMC-20cb97a35af5097e9d3b2062c0dfcb5f2e5fff5c.zip
Sync from quickmods
Diffstat (limited to 'logic/net/ByteArrayDownload.cpp')
-rw-r--r--logic/net/ByteArrayDownload.cpp26
1 files changed, 26 insertions, 0 deletions
diff --git a/logic/net/ByteArrayDownload.cpp b/logic/net/ByteArrayDownload.cpp
index 27d2a250..a8d1d330 100644
--- a/logic/net/ByteArrayDownload.cpp
+++ b/logic/net/ByteArrayDownload.cpp
@@ -53,16 +53,42 @@ void ByteArrayDownload::downloadError(QNetworkReply::NetworkError error)
QLOG_ERROR() << "Error getting URL:" << m_url.toString().toLocal8Bit()
<< "Network error: " << error;
m_status = Job_Failed;
+ m_errorString = m_reply->errorString();
}
void ByteArrayDownload::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)
{
// nothing went wrong...
m_status = Job_Finished;
m_data = m_reply->readAll();
+ m_content_type = m_reply->header(QNetworkRequest::ContentTypeHeader).toString();
m_reply.reset();
emit succeeded(m_index_within_job);
return;