1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-08-16 02:54:33 +02:00

Merge pull request #316 from theli-ua/user_agent

Add ability for resolvers to specify user agent string
This commit is contained in:
Dominik Schmidt
2015-09-01 22:44:47 +02:00
3 changed files with 16 additions and 3 deletions

View File

@@ -951,6 +951,8 @@ JSResolverHelper::nativeAsyncRequestDone( int requestId, NetworkReply* reply )
map["status"] = reply->reply()->attribute( QNetworkRequest::HttpStatusCodeAttribute ).toInt();
map["statusText"] = QString("%1 %2").arg( map["status"].toString() )
.arg( reply->reply()->attribute( QNetworkRequest::HttpReasonPhraseAttribute ).toString() );
if (reply->reply()->hasRawHeader( "Content-Type" ))
map["contentType"] = reply->reply()->rawHeader( "Content-Type" );
bool ok = false;
QString json = QString::fromUtf8( TomahawkUtils::toJson( map, &ok ) );

View File

@@ -148,6 +148,12 @@ NetworkReply::load( const QUrl& url )
m_formerUrls << url.toString();
QNetworkRequest request( url );
//Carryover User-Agent
if ( m_reply->request().hasRawHeader( "User-Agent" ))
{
request.setRawHeader( "User-Agent", m_reply->request().rawHeader( "User-Agent" ) );
}
Q_ASSERT( Tomahawk::Utils::nam() != 0 );
QNetworkAccessManager::Operation op = m_reply->operation();