Skip to content
Permalink
Browse files

network manager: include QGIS version in user-agent string (related to

  • Loading branch information
jef-n committed Feb 18, 2014
1 parent 22b2d58 commit 266c592c86fe41a76edc13baa817aee93794e401
Showing with 7 additions and 1 deletion.
  1. +7 −1 src/core/qgsnetworkaccessmanager.cpp
@@ -22,6 +22,7 @@
#include <qgsnetworkaccessmanager.h>
#include <qgsmessagelog.h>
#include <qgslogger.h>
#include <qgis.h>

#include <QUrl>
#include <QSettings>
@@ -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 );

1 comment on commit 266c592

@palmerj

This comment has been minimized.

Copy link
Contributor

@palmerj palmerj commented on 266c592 Feb 19, 2014

Thanks @jef-n !

Please sign in to comment.
You can’t perform that action at this time.