1
0
mirror of https://github.com/d47081/qBittorrent.git synced 2025-01-22 20:44:15 +00:00

Fix url encoded ampersand issue in RSS

This commit is contained in:
Christophe Dumez 2010-05-12 19:41:12 +00:00
parent bf73c47bc5
commit 119bda1595
2 changed files with 10 additions and 17 deletions

View File

@ -40,21 +40,15 @@ enum ProxyType {HTTP=1, SOCKS5=2, HTTP_PW=3, SOCKS5_PW=4, SOCKS4=5};
/** Download Thread **/ /** Download Thread **/
downloadThread::downloadThread(QObject* parent) : QObject(parent) { downloadThread::downloadThread(QObject* parent) : QObject(parent) {
networkManager = new QNetworkAccessManager(this); connect(&networkManager, SIGNAL(finished (QNetworkReply*)), this, SLOT(processDlFinished(QNetworkReply*)));
connect(networkManager, SIGNAL(finished (QNetworkReply*)), this, SLOT(processDlFinished(QNetworkReply*)));
#ifndef QT_NO_OPENSSL #ifndef QT_NO_OPENSSL
connect(networkManager, SIGNAL(sslErrors(QNetworkReply*,QList<QSslError>)), this, SLOT(ignoreSslErrors(QNetworkReply*,QList<QSslError>))); connect(&networkManager, SIGNAL(sslErrors(QNetworkReply*,QList<QSslError>)), this, SLOT(ignoreSslErrors(QNetworkReply*,QList<QSslError>)));
#endif #endif
} }
downloadThread::~downloadThread(){
qDebug("Deleting network manager");
delete networkManager;
qDebug("Deleted network manager");
}
void downloadThread::processDlFinished(QNetworkReply* reply) { void downloadThread::processDlFinished(QNetworkReply* reply) {
QString url = reply->url().toString(); QString url = reply->url().toEncoded().data();
qDebug("Download finished: %s", qPrintable(url));
if(reply->error() != QNetworkReply::NoError) { if(reply->error() != QNetworkReply::NoError) {
// Failure // Failure
qDebug("Download failure (%s), reason: %s", qPrintable(url), qPrintable(errorCodeToString(reply->error()))); qDebug("Download failure (%s), reason: %s", qPrintable(url), qPrintable(errorCodeToString(reply->error())));
@ -110,14 +104,14 @@ QNetworkReply* downloadThread::downloadUrl(QString url){
// Update proxy settings // Update proxy settings
applyProxySettings(); applyProxySettings();
// Process download request // Process download request
QNetworkRequest request; qDebug("url is %s", qPrintable(url));
request.setUrl(QUrl::fromEncoded(url.toLocal8Bit())); const QUrl &qurl = QUrl::fromEncoded(url.toLocal8Bit());
QNetworkRequest request(qurl);
// Spoof Firefox 3.5 user agent to avoid // Spoof Firefox 3.5 user agent to avoid
// Web server banning // Web server banning
request.setRawHeader("User-Agent", "Mozilla/5.0 (X11; U; Linux i686 (x86_64); en-US; rv:1.9.1.5) Gecko/20091102 Firefox/3.5.5"); request.setRawHeader("User-Agent", "Mozilla/5.0 (X11; U; Linux i686 (x86_64); en-US; rv:1.9.1.5) Gecko/20091102 Firefox/3.5.5");
qDebug("Downloading %s...", request.url().toEncoded().data()); qDebug("Downloading %s...", request.url().toEncoded().data());
qDebug("Header: %s", qPrintable(request.header(QNetworkRequest::LocationHeader).toString())); return networkManager.get(request);
return networkManager->get(request);
} }
void downloadThread::checkDownloadSize(qint64 bytesReceived, qint64 bytesTotal) { void downloadThread::checkDownloadSize(qint64 bytesReceived, qint64 bytesTotal) {
@ -169,7 +163,7 @@ void downloadThread::applyProxySettings() {
} else { } else {
proxy.setType(QNetworkProxy::NoProxy); proxy.setType(QNetworkProxy::NoProxy);
} }
networkManager->setProxy(proxy); networkManager.setProxy(proxy);
} }
QString downloadThread::errorCodeToString(QNetworkReply::NetworkError status) { QString downloadThread::errorCodeToString(QNetworkReply::NetworkError status) {

View File

@ -42,7 +42,7 @@ class downloadThread : public QObject {
Q_OBJECT Q_OBJECT
private: private:
QNetworkAccessManager *networkManager; QNetworkAccessManager networkManager;
QHash<QString, QString> redirect_mapping; QHash<QString, QString> redirect_mapping;
signals: signals:
@ -51,7 +51,6 @@ signals:
public: public:
downloadThread(QObject* parent); downloadThread(QObject* parent);
~downloadThread();
QNetworkReply* downloadUrl(QString url); QNetworkReply* downloadUrl(QString url);
void downloadTorrentUrl(QString url); void downloadTorrentUrl(QString url);
//void setProxy(QString IP, int port, QString username, QString password); //void setProxy(QString IP, int port, QString username, QString password);