jenkins-bot has submitted this change and it was merged.
Change subject: Add username and sitename to the user-agent
......................................................................
Add username and sitename to the user-agent
Bug: T100111
Change-Id: If47e05f888b749ca37be7c92f0344bdcfae61ed7
---
M pywikibot/comms/http.py
1 file changed, 6 insertions(+), 4 deletions(-)
Approvals:
John Vandenberg: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/comms/http.py b/pywikibot/comms/http.py
index df2911a..90207aa 100644
--- a/pywikibot/comms/http.py
+++ b/pywikibot/comms/http.py
@@ -83,9 +83,12 @@
if retry is None:
retry = config.retry_on_fail
-
+ if hasattr(site, '_userName') and site._userName[0]:
+ user_name = urllib.quote(site._userName[0])
+ else:
+ user_name = 'Unknown'
headers = {
- 'User-agent': useragent,
+ 'User-agent': '%s %s' % (useragent, user_name),
#'Accept-Language': config.mylang,
#'Accept-Charset': config.textfile_encoding,
#'Keep-Alive': '115',
@@ -93,7 +96,6 @@
#'Cache-Control': 'max-age=0',
#'': '',
}
-
if not no_hostname and site.cookies(sysop = sysop):
headers['Cookie'] = site.cookies(sysop = sysop)
if compress:
@@ -239,7 +241,7 @@
u'replaced by \\ufffd.' % uri)
else:
pywikibot.error(u'Invalid characters found on %s://%s%s, '
- u'replaced by \\ufffd.'
+ u'replaced by \\ufffd.'
% (site.protocol(), site.hostname(), uri))
# We use error='replace' in case of bad encoding.
text = unicode(text, charset, errors = 'replace')
--
To view, visit
https://gerrit.wikimedia.org/r/213217
To unsubscribe, visit
https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: If47e05f888b749ca37be7c92f0344bdcfae61ed7
Gerrit-PatchSet: 3
Gerrit-Project: pywikibot/compat
Gerrit-Branch: master
Gerrit-Owner: Ladsgroup <ladsgroup(a)gmail.com>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Merlijn van Deen <valhallasw(a)arctus.nl>
Gerrit-Reviewer: Multichill <maarten(a)mdammers.nl>
Gerrit-Reviewer: jenkins-bot <>