Skip to content

Commit

Permalink
network manager: include QGIS version in user-agent string (related to
Browse files Browse the repository at this point in the history
  • Loading branch information
jef-n committed Feb 18, 2014
1 parent 22b2d58 commit 266c592
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/core/qgsnetworkaccessmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include <qgsnetworkaccessmanager.h>
#include <qgsmessagelog.h>
#include <qgslogger.h>
#include <qgis.h>

#include <QUrl>
#include <QSettings>
Expand Down Expand Up @@ -136,7 +137,12 @@ QNetworkReply *QgsNetworkAccessManager::createRequest( QNetworkAccessManager::Op
QSettings s;

QNetworkRequest *pReq(( QNetworkRequest * ) &req ); // hack user agent
pReq->setRawHeader( "User-Agent", s.value( "/qgis/networkAndProxy/userAgent", "Mozilla/5.0" ).toByteArray() );

QString userAgent = s.value( "/qgis/networkAndProxy/userAgent", "Mozilla/5.0" ).toString();
if( !userAgent.isEmpty() )
userAgent += " ";
userAgent += QString( "QGIS/%1" ).arg( QGis::QGIS_VERSION );
pReq->setRawHeader( "User-Agent", userAgent.toUtf8() );

emit requestAboutToBeCreated( op, req, outgoingData );
QNetworkReply *reply = QNetworkAccessManager::createRequest( op, req, outgoingData );
Expand Down

1 comment on commit 266c592

@palmerj
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @jef-n !

Please sign in to comment.