From a14ffe32c164859afb9cfe97bdec0f76d6802288 Mon Sep 17 00:00:00 2001 From: Thomas Herve Date: Fri, 10 Mar 2017 17:09:17 +0100 Subject: [PATCH] Add missing content type in Swift objects This sets the content type on all JSON objects stored in Swift when using that backend. Change-Id: I972e3f43cbb370847a1c8b288546760092c14983 --- zaqar/storage/swift/claims.py | 4 ++++ zaqar/storage/swift/messages.py | 1 + zaqar/storage/swift/subscriptions.py | 3 ++- 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/zaqar/storage/swift/claims.py b/zaqar/storage/swift/claims.py index ae7dc7605..b5e4ffbd6 100644 --- a/zaqar/storage/swift/claims.py +++ b/zaqar/storage/swift/claims.py @@ -119,6 +119,7 @@ class ClaimController(storage.Claim): utils._message_container(queue, project), msg['id'], content, + content_type='application/json', headers={'x-object-meta-clientid': msg['client_uuid'], 'if-match': md5, 'x-object-meta-claimid': claim_id, @@ -137,6 +138,7 @@ class ClaimController(storage.Claim): utils._claim_container(queue, project), claim_id, jsonutils.dumps([msg['id'] for msg in claimed]), + content_type='application/json', headers={'x-delete-after': ttl} ) @@ -152,6 +154,7 @@ class ClaimController(storage.Claim): raise self._client.put_object(container, claim_id, obj, + content_type='application/json', headers={'x-delete-after': metadata['ttl']}) def delete(self, queue, claim_id, project=None): @@ -176,6 +179,7 @@ class ClaimController(storage.Claim): utils._message_container(queue, project), msg_id, content, + content_type='application/json', headers={'x-object-meta-clientid': client_id, 'if-match': md5, 'x-delete-at': headers['x-delete-at']}) diff --git a/zaqar/storage/swift/messages.py b/zaqar/storage/swift/messages.py index 3c5c2c817..f1ddb4666 100644 --- a/zaqar/storage/swift/messages.py +++ b/zaqar/storage/swift/messages.py @@ -220,6 +220,7 @@ class MessageController(storage.Message): utils._message_container(queue, project), slug, contents=contents, + content_type='application/json', headers={ 'x-object-meta-clientid': str(client_uuid), 'x-delete-after': msg['ttl']}) diff --git a/zaqar/storage/swift/subscriptions.py b/zaqar/storage/swift/subscriptions.py index cbc73d238..0058fed3d 100644 --- a/zaqar/storage/swift/subscriptions.py +++ b/zaqar/storage/swift/subscriptions.py @@ -98,7 +98,7 @@ class SubscriptionController(storage.Subscription): 'confirmed': False} utils._put_or_create_container( self._client, container, slug, contents=jsonutils.dumps(data), - headers={'x-delete-after': ttl}) + content_type='application/json', headers={'x-delete-after': ttl}) return slug def update(self, queue, subscription_id, project=None, **kwargs): @@ -124,6 +124,7 @@ class SubscriptionController(storage.Subscription): self._client.put_object(container, subscription_id, contents=jsonutils.dumps(data), + content_type='application/json', headers={'x-delete-after': ttl}) def exists(self, queue, subscription_id, project=None):