~avishai-ish-shalom/cloud-init/chef-refactor

« back to all changes in this revision

Viewing changes to cloudinit/util.py

  • Committer: Scott Moser
  • Date: 2013-04-25 18:03:16 UTC
  • mfrom: (811.1.2 trunk.lp1172742)
  • Revision ID: smoser@ubuntu.com-20130425180316-ekroe007n90vxuwf
Fix issue in readurl with requests, support passing through headers_cb

This adds the 'headers_cb' option to pass all the way through to readurl.
It also makes requests for user-data not retry (as a 404 indicates "no
user-data").

Show diffs side-by-side

added added

removed removed

Lines of Context:
671
671
 
672
672
 
673
673
def read_file_or_url(url, timeout=5, retries=10,
674
 
                     headers=None, data=None, sec_between=1, ssl_details=None):
 
674
                     headers=None, data=None, sec_between=1, ssl_details=None,
 
675
                     headers_cb=None):
675
676
    url = url.lstrip()
676
677
    if url.startswith("/"):
677
678
        url = "file://%s" % url
685
686
                                  timeout=timeout,
686
687
                                  retries=retries,
687
688
                                  headers=headers,
 
689
                                  headers_cb=headers_cb,
688
690
                                  data=data,
689
691
                                  sec_between=sec_between,
690
692
                                  ssl_details=ssl_details)