Set default user-agent for module_utils.urls fetch_url (#27095)

The HTTP User-Agent "ansible-httpget" is already kind of the default,
it being the default value provided by the `url_argument_spec` helper
method. Yet, it may not be practical for all modules to get their
argument_spec that way.

Without a default User-Agent we fall back on the library
User-Agent. That being something like "Python-urllib/2.7".

While I'm no big fan of web servers making decisions based on the
provided User-Agent I still think that part of being a well-behaved
HTTP client is to provide an informative User-Agent. Not to mention
that it's a good thing for Ansible to behave consistently.

Indirectly fixes #26239
pull/27147/head
Andreas Olsson 7 years ago committed by Matt Davis
parent 7c65272e2d
commit 063f5d0ca8

@ -1020,7 +1020,7 @@ def fetch_url(module, url, data=None, headers=None, method=None,
username = module.params.get('url_username', '') username = module.params.get('url_username', '')
password = module.params.get('url_password', '') password = module.params.get('url_password', '')
http_agent = module.params.get('http_agent', None) http_agent = module.params.get('http_agent', 'ansible-httpget')
force_basic_auth = module.params.get('force_basic_auth', '') force_basic_auth = module.params.get('force_basic_auth', '')
follow_redirects = module.params.get('follow_redirects', 'urllib2') follow_redirects = module.params.get('follow_redirects', 'urllib2')

Loading…
Cancel
Save