From 7bc09dfdea0893a49e50005b22b426ae21c11d22 Mon Sep 17 00:00:00 2001 From: Arnaud JOST Date: Wed, 18 Feb 2015 11:56:11 +0100 Subject: [PATCH] Add support of x-remove- headers for container-sync If the used tool to send header doesn't support empty headers (older versions of curl), x-remove can be used to remove metadata. sync-key and sync-to metadata, used by container-sync, can now be removed using x-remove headers. Change-Id: I0edb4d5425a99d20a973aa4fceaf9af6c2ddecc0 --- swift/proxy/controllers/container.py | 4 +++- test/unit/proxy/test_server.py | 6 ++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/swift/proxy/controllers/container.py b/swift/proxy/controllers/container.py index 355bd8a7ba..fb422e68db 100644 --- a/swift/proxy/controllers/container.py +++ b/swift/proxy/controllers/container.py @@ -46,7 +46,9 @@ class ContainerController(Controller): st = self.server_type.lower() return ['x-remove-%s-read' % st, 'x-remove-%s-write' % st, - 'x-remove-versions-location'] + 'x-remove-versions-location', + 'x-remove-%s-sync-key' % st, + 'x-remove-%s-sync-to' % st] def _convert_policy_to_index(self, req): """ diff --git a/test/unit/proxy/test_server.py b/test/unit/proxy/test_server.py index 59dd320a45..6d5bf0ed54 100644 --- a/test/unit/proxy/test_server.py +++ b/test/unit/proxy/test_server.py @@ -5345,13 +5345,15 @@ class TestContainerController(unittest.TestCase): def test_transfer_headers(self): src_headers = {'x-remove-versions-location': 'x', - 'x-container-read': '*:user'} + 'x-container-read': '*:user', + 'x-remove-container-sync-key': 'x'} dst_headers = {'x-versions-location': 'backup'} controller = swift.proxy.controllers.ContainerController(self.app, 'a', 'c') controller.transfer_headers(src_headers, dst_headers) expected_headers = {'x-versions-location': '', - 'x-container-read': '*:user'} + 'x-container-read': '*:user', + 'x-container-sync-key': ''} self.assertEqual(dst_headers, expected_headers) def assert_status_map(self, method, statuses, expected,