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

Allow setting User-Agent via nativeAsyncRequest

This commit is contained in:
Anton Romanov
2015-08-19 15:40:07 -07:00
parent 82c9f5cd52
commit eaad1f28df
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();