summaryrefslogtreecommitdiff
path: root/cloudinit/url_helper.py
diff options
context:
space:
mode:
authorScott Moser <smoser@ubuntu.com>2015-08-31 12:28:09 -0400
committerScott Moser <smoser@ubuntu.com>2015-08-31 12:28:09 -0400
commit6010d3c8b903d7dae8b0ff11ec45c6f78ea50cc8 (patch)
treef1e8d4bb5eceedec3dff37bba563c078e9841c35 /cloudinit/url_helper.py
parent60a9ebaba73b2154ce841d36978e317197b66945 (diff)
downloadvyos-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.py12
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