diff options
author | Charles Hsu <charles0126@gmail.com> | 2016-09-19 23:18:18 +0800 |
---|---|---|
committer | Charles Hsu <charles0126@gmail.com> | 2016-11-07 13:18:29 +0800 |
commit | 6cf2bd6626df8e4c68bd5463d9b030e315f76b42 (patch) | |
tree | f1b8393f5080d42d9530e7308245b34b30e33972 /swiftclient/utils.py | |
parent | 0ec6b7b162a7b98ca3fad515de17d8f8a88dda72 (diff) | |
download | python-swiftclient-6cf2bd6626df8e4c68bd5463d9b030e315f76b42.tar.gz |
Add additional headers for HEAD/GET/DELETE requests.
Change-Id: I69276ba711057c122f97deac412e492e313c34dd
Closes-Bug: 1615830
Diffstat (limited to 'swiftclient/utils.py')
-rw-r--r-- | swiftclient/utils.py | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/swiftclient/utils.py b/swiftclient/utils.py index 0d1104e..e14602d 100644 --- a/swiftclient/utils.py +++ b/swiftclient/utils.py @@ -146,6 +146,20 @@ def parse_api_response(headers, body): return json.loads(body.decode(charset)) +def split_request_headers(options, prefix=''): + headers = {} + for item in options: + split_item = item.split(':', 1) + if len(split_item) == 2: + headers[(prefix + split_item[0]).title()] = split_item[1].strip() + else: + raise ValueError( + "Metadata parameter %s must contain a ':'.\n%s" + % (item, "Example: 'Color:Blue' or 'Size:Large'") + ) + return headers + + def report_traceback(): """ Reports a timestamp and full traceback for a given exception. |