From 6c1be607f134f56bffebb7de71b18fadf918dcaa Mon Sep 17 00:00:00 2001 From: kracekumar Date: Thu, 5 Dec 2013 12:11:35 +0530 Subject: [PATCH] Made default_user_agent reusable This is not exciting change, but will help for people who wants to change name of user agent alone. Also name can be unicode. --- requests/utils.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/requests/utils.py b/requests/utils.py index 57292c3..24fbf56 100644 --- a/requests/utils.py +++ b/requests/utils.py @@ -437,7 +437,7 @@ def get_environ_proxies(url): return getproxies() -def default_user_agent(): +def default_user_agent(name=u"python-requests"): """Return a string representing the default user agent.""" _implementation = platform.python_implementation() @@ -463,9 +463,9 @@ def default_user_agent(): p_system = 'Unknown' p_release = 'Unknown' - return " ".join(['python-requests/%s' % __version__, - '%s/%s' % (_implementation, _implementation_version), - '%s/%s' % (p_system, p_release)]) + return " ".join([u'%s/%s' % (name, __version__), + u'%s/%s' % (_implementation, _implementation_version), + u'%s/%s' % (p_system, p_release)]) def default_headers(): -- 2.7.4