From 68f271aae2c45cd65d5a93659a812f9b8e823212 Mon Sep 17 00:00:00 2001 From: Chris Buccella Date: Thu, 6 Nov 2014 15:33:14 -0500 Subject: Check that content_type header exists before using When downloading an object, the content_type header is inspected to determine if a directory needs to be created. This header is assumed to always be in the response; if it isn't an Exception is raised. swiftclient should not assume content_type will always be set. Change-Id: I156195c02b6e0bc398fa962eb1f78c4dbddd1596 --- swiftclient/service.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'swiftclient/service.py') diff --git a/swiftclient/service.py b/swiftclient/service.py index 55e6daa..c74e0a5 100644 --- a/swiftclient/service.py +++ b/swiftclient/service.py @@ -1020,7 +1020,8 @@ class SwiftService(object): try: no_file = options['no_download'] content_type = headers.get('content-type') - if content_type.split(';', 1)[0] == 'text/directory': + if (content_type and + content_type.split(';', 1)[0] == 'text/directory'): make_dir = not no_file and out_file != "-" if make_dir and not isdir(path): mkdirs(path) -- cgit v1.2.1