Made default_user_agent reusable
authorkracekumar <kracethekingmaker@gmail.com>
Thu, 5 Dec 2013 06:41:35 +0000 (12:11 +0530)
committerkracekumar <kracethekingmaker@gmail.com>
Thu, 5 Dec 2013 06:41:35 +0000 (12:11 +0530)
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

index 57292c3..24fbf56 100644 (file)
@@ -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():