Skip to content
Myr

Include the implementation and implementation version number in the default User-Agent

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Donald Stufft · committed by Donald Stufft · parent 808b0ad · Browse files · 1 file+29 added−4 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+29 added−4 removed

  • other:+29 added−4 removed

1 file+29 added−4 removed

modified:requests/defaults.py+29 added-4 removed
24 unmodified lines
25"""2627SCHEMAS = ['http', 'https']2829import platform30import sys3132from . import __version__3334defaults = dict()353637_implementation = platform.python_implementation()3839if _implementation == 'CPython':40 _implementation_version = platform.python_version()41elif _implementation == 'PyPy':42 _implementation_version = '%s.%s.%s' % (43 sys.pypy_version_info.major,44 sys.pypy_version_info.minor,45 sys.pypy_version_info.micro46 )47 if sys.pypy_version_info.releaselevel != 'final':48 _implementation_version = ''.join([_implementation_version, sys.pypy_version_info.releaselevel])49elif _implementation == 'Jython':50 # @@@ Is there a better way of getting this?51 _implementation_version = platform.python_version()52elif _implementation == 'IronPython':53 # @@@ Is there a better way of getting this?54 _implementation_version = platform.python_version()55else:56 _implementation_version = 'Unknown'575859defaults['base_headers'] = {35 'User-Agent': 'python-requests/%s' % __version__,36 'Accept-Encoding': ', '.join(('identity', 'deflate', 'compress', 'gzip')),60 'User-Agent': " ".join([61 'python-requests/%s' % __version__,62 '%s/%s' % (_implementation, _implementation_version),63 ]),64 'Accept': '*/*'65}6667defaults['verbose'] = None
7 unmodified lines
75defaults['keep_alive'] = True76defaults['encode_uri'] = True77defaults['trust_env'] = True78defaults['store_cookies'] = True5253