diff options
author | Scott Moser <smoser@ubuntu.com> | 2015-08-31 12:28:09 -0400 |
---|---|---|
committer | Scott Moser <smoser@ubuntu.com> | 2015-08-31 12:28:09 -0400 |
commit | 6010d3c8b903d7dae8b0ff11ec45c6f78ea50cc8 (patch) | |
tree | f1e8d4bb5eceedec3dff37bba563c078e9841c35 /cloudinit/url_helper.py | |
parent | 60a9ebaba73b2154ce841d36978e317197b66945 (diff) | |
download | vyos-cloud-init-6010d3c8b903d7dae8b0ff11ec45c6f78ea50cc8.tar.gz vyos-cloud-init-6010d3c8b903d7dae8b0ff11ec45c6f78ea50cc8.zip |
readurl: if headers are provided still provide base headers
we want cloud-init user agent to be present even if the user
provided some headers. In the event that they provided User-Agent,
this will respect their wishes.
Diffstat (limited to 'cloudinit/url_helper.py')
-rw-r--r-- | cloudinit/url_helper.py | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/cloudinit/url_helper.py b/cloudinit/url_helper.py index ce6b5444..a93847ce 100644 --- a/cloudinit/url_helper.py +++ b/cloudinit/url_helper.py @@ -211,10 +211,14 @@ def readurl(url, data=None, timeout=None, retries=0, sec_between=1, manual_tries = 1 if retries: manual_tries = max(int(retries) + 1, 1) - if not headers: - headers = { - 'User-Agent': 'Cloud-Init/%s' % (version.version_string()), - } + + def_headers = { + 'User-Agent': 'Cloud-Init/%s' % (version.version_string()), + } + if headers: + def_headers.update(headers) + headers = def_headers + if not headers_cb: def _cb(url): return headers |