Allow for additional headers sent with curl() HTTP requests to be set in ManagedInstalls.plist

git-svn-id: http://munki.googlecode.com/svn/trunk@740 a4e17f2e-e282-11dd-95e1-755cbddbdd66
This commit is contained in:
Justin McWilliams
2010-09-10 00:15:45 +00:00
parent 0b667a61b2
commit 5873a12d26
+19 -2
View File
@@ -1058,8 +1058,8 @@ def verifySoftwarePackageIntegrity(manifestitem, file_path, item_pl, item_key):
none: No integrity check is performed.
hash: Integrity check is performed by calcualting a SHA-256 hash of
the given file and comparing it against the reference value in
catalog. Only applies for package plists that contain the
item_key; for packages without the item_key, verifcation always
catalog. Only applies for package plists that contain the
item_key; for packages without the item_key, verifcation always
returns True.
hash_strict: Same as hash, but returns False for package plists that
do not contain the item_key.
@@ -2169,6 +2169,23 @@ def curl(url, destinationpath, onlyifnewer=False, etag=None, resume=False,
else:
os.remove(destinationpath)
# Add any additional headers specified in ManagedInstalls.plist.
# AdditionalHttpHeaders must be an array of strings with valid HTTP
# header format. For example:
# <key>AdditionalHttpHeaders</key>
# <array>
# <string>Key-With-Optional-Dahes: Foo Value</string>
# <string>another-custom-header: bar value</string>
# </array>
custom_headers = munkicommon.pref('AdditionalHttpHeaders')
if custom_headers:
for custom_header in custom_headers:
if re.search(r'^[\w-]+:.+', custom_header):
print >> fileobj, ('header = "%s"' % custom_header)
else:
munkicommon.display_warning(
"Skipping invalid HTTP header: %s" % custom_header)
fileobj.close()
except:
raise CurlError(-5, "Error writing curl directive")