Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def set_user_agent(self, user_agent):
"""Replaces the current user agent in the requests session headers."""
# set a default user_agent if not specified
if user_agent is None:
requests_ua = requests.utils.default_user_agent()
user_agent = '%s (%s/%s)' % (requests_ua, __title__, __version__)
# the requests module uses a case-insensitive dict for session headers
self.session.headers['User-agent'] = user_agent