diff --git a/Changelog b/Changelog index 233eb5f92..5ff4b9c92 100644 --- a/Changelog +++ b/Changelog @@ -1,6 +1,7 @@ * Unreleased - Christophe Dumez - v2.1.3 - BUGFIX: Fix "Append .!qB extension to complete files" (libtorrent v0.15) - BUGFIX: Make sure bandwidth limiting dialogs are centered on screen + - BUGFIX: Added support for HTTP redirection * Sun Jan 24 2010 - Christophe Dumez - v2.1.2 - FEATURE: Added back file prioritizing in a torrent diff --git a/src/downloadthread.cpp b/src/downloadthread.cpp index e9f3f1a93..957874073 100644 --- a/src/downloadthread.cpp +++ b/src/downloadthread.cpp @@ -56,6 +56,18 @@ void downloadThread::processDlFinished(QNetworkReply* reply) { // Failure emit downloadFailure(url, errorCodeToString(reply->error())); } else { + QVariant redirection = reply->attribute(QNetworkRequest::RedirectionTargetAttribute); + if(redirection.isValid()) { + // We should redirect + qDebug("Redirecting from %s to %s", url.toLocal8Bit().data(), redirection.toUrl().toString().toLocal8Bit().data()); + redirect_mapping.insert(redirection.toUrl().toString(), url); + downloadUrl(redirection.toUrl().toString()); + return; + } + // Checking if it was redirecting, restoring initial URL + if(redirect_mapping.contains(url)) { + url = redirect_mapping.take(url); + } // Success QString filePath; QTemporaryFile tmpfile; diff --git a/src/downloadthread.h b/src/downloadthread.h index af5ee8abc..1d3bbd871 100644 --- a/src/downloadthread.h +++ b/src/downloadthread.h @@ -33,6 +33,7 @@ #include #include +#include class QNetworkAccessManager; @@ -41,6 +42,7 @@ class downloadThread : public QObject { private: QNetworkAccessManager *networkManager; + QHash redirect_mapping; signals: void downloadFinished(QString url, QString file_path);