mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-02-26 21:03:31 +01:00
Prevent redirect loops
This commit is contained in:
parent
d755415704
commit
95dac14782
@ -68,6 +68,7 @@ void
|
||||
NetworkReply::load( const QUrl& url )
|
||||
{
|
||||
m_url = url;
|
||||
m_formerUrls << url;
|
||||
QNetworkRequest request( url );
|
||||
|
||||
Q_ASSERT( Tomahawk::Utils::nam() != 0 );
|
||||
@ -101,7 +102,7 @@ NetworkReply::networkLoadFinished()
|
||||
}
|
||||
|
||||
QVariant redir = m_reply->attribute( QNetworkRequest::RedirectionTargetAttribute );
|
||||
if ( redir.isValid() && !redir.toUrl().isEmpty() )
|
||||
if ( redir.isValid() && !redir.toUrl().isEmpty() && m_formerUrls.count( redir.toUrl().toString() ) < maxSameRedirects && m_formerUrls.count() < maxRedirects )
|
||||
{
|
||||
tDebug( LOGVERBOSE ) << Q_FUNC_INFO << "Redirected HTTP request to" << redir;
|
||||
if ( m_blacklistedHosts.contains( redir.toUrl().host() ) )
|
||||
|
@ -38,6 +38,9 @@ public:
|
||||
void blacklistHostFromRedirection( const QString& host );
|
||||
QNetworkReply* reply() const { return m_reply; }
|
||||
|
||||
static const uint maxRedirects = 100;
|
||||
static const uint maxSameRedirects = 5;
|
||||
|
||||
signals:
|
||||
void redirected();
|
||||
|
||||
@ -53,6 +56,7 @@ private:
|
||||
void load( const QUrl& url );
|
||||
|
||||
QStringList m_blacklistedHosts;
|
||||
QStringList m_formerUrls;
|
||||
QNetworkReply* m_reply;
|
||||
QUrl m_url;
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user