summaryrefslogtreecommitdiff
path: root/tests/functional/test_swiftclient.py
diff options
context:
space:
mode:
authorLisak, Peter <peter.lisak@firma.seznam.cz>2015-10-06 10:08:02 +0200
committerAlistair Coles <alistair.coles@hp.com>2015-10-22 08:54:13 +0000
commitdf1f4f3e3932a9653b7b1731e121c51c7fdf31e1 (patch)
treee65ba15c9a6ba7c58cd49c80b94cd12a89ef46ed /tests/functional/test_swiftclient.py
parent9fed7ed5e1f6dd3e589a35e3ee4abecb676f2188 (diff)
downloadpython-swiftclient-df1f4f3e3932a9653b7b1731e121c51c7fdf31e1.tar.gz
swiftclient content-type header
According to help `swift upload -h` you can add a customized request header 'Content-Type'. But actually it is ignored (cleared and default is used) if subcommand is upload. Subcommand post works as expected in help. Bug fix: Use 'Content-Type' from the customized request headers also if uploading. Change-Id: If0d1354b6214b909527341078fe1769aa6587457
Diffstat (limited to 'tests/functional/test_swiftclient.py')
-rw-r--r--tests/functional/test_swiftclient.py34
1 files changed, 34 insertions, 0 deletions
diff --git a/tests/functional/test_swiftclient.py b/tests/functional/test_swiftclient.py
index 2be280d..35a5ea7 100644
--- a/tests/functional/test_swiftclient.py
+++ b/tests/functional/test_swiftclient.py
@@ -217,6 +217,40 @@ class TestFunctional(testtools.TestCase):
self.assertEqual('application/octet-stream',
hdrs.get('content-type'))
+ # Same but with content_type
+ self.conn.put_object(
+ self.containername, self.objectname,
+ content_type='text/plain', contents=self.test_data)
+ hdrs = self.conn.head_object(self.containername, self.objectname)
+ self.assertEqual(str(len(self.test_data)),
+ hdrs.get('content-length'))
+ self.assertEqual(self.etag, hdrs.get('etag'))
+ self.assertEqual('text/plain',
+ hdrs.get('content-type'))
+
+ # Same but with content-type in headers
+ self.conn.put_object(
+ self.containername, self.objectname,
+ headers={'Content-Type': 'text/plain'}, contents=self.test_data)
+ hdrs = self.conn.head_object(self.containername, self.objectname)
+ self.assertEqual(str(len(self.test_data)),
+ hdrs.get('content-length'))
+ self.assertEqual(self.etag, hdrs.get('etag'))
+ self.assertEqual('text/plain',
+ hdrs.get('content-type'))
+
+ # content_type rewrites content-type in headers
+ self.conn.put_object(
+ self.containername, self.objectname,
+ content_type='image/jpeg',
+ headers={'Content-Type': 'text/plain'}, contents=self.test_data)
+ hdrs = self.conn.head_object(self.containername, self.objectname)
+ self.assertEqual(str(len(self.test_data)),
+ hdrs.get('content-length'))
+ self.assertEqual(self.etag, hdrs.get('etag'))
+ self.assertEqual('image/jpeg',
+ hdrs.get('content-type'))
+
# Same but with content-length
self.conn.put_object(
self.containername, self.objectname,