mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2024-11-29 13:58:51 +03:00
- Download thread now supports HTTP redirection
This commit is contained in:
parent
83cf3aebab
commit
dc87aa3d5c
2 changed files with 14 additions and 0 deletions
|
@ -56,6 +56,18 @@ void downloadThread::processDlFinished(QNetworkReply* reply) {
|
||||||
// Failure
|
// Failure
|
||||||
emit downloadFailure(url, errorCodeToString(reply->error()));
|
emit downloadFailure(url, errorCodeToString(reply->error()));
|
||||||
} else {
|
} 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
|
// Success
|
||||||
QString filePath;
|
QString filePath;
|
||||||
QTemporaryFile tmpfile;
|
QTemporaryFile tmpfile;
|
||||||
|
|
|
@ -33,6 +33,7 @@
|
||||||
|
|
||||||
#include <QNetworkReply>
|
#include <QNetworkReply>
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
|
#include <QHash>
|
||||||
|
|
||||||
class QNetworkAccessManager;
|
class QNetworkAccessManager;
|
||||||
|
|
||||||
|
@ -41,6 +42,7 @@ class downloadThread : public QObject {
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QNetworkAccessManager *networkManager;
|
QNetworkAccessManager *networkManager;
|
||||||
|
QHash<QString, QString> redirect_mapping;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void downloadFinished(QString url, QString file_path);
|
void downloadFinished(QString url, QString file_path);
|
||||||
|
|
Loading…
Reference in a new issue