From 40f46e245c2465ad1561f78ca1dcbc9272974ea7 Mon Sep 17 00:00:00 2001 From: Samuel Merritt Date: Fri, 26 Oct 2012 10:11:22 -0700 Subject: [PATCH] Allow unsetting of X-Container-Sync-To header. Fixes bug 1071790. Change-Id: Ic0509190b9994e7d983bcf20daa64a650cc974cb --- swift/common/utils.py | 2 ++ test/unit/common/test_utils.py | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/swift/common/utils.py b/swift/common/utils.py index 19db1b2bdf..0d27a90f56 100644 --- a/swift/common/utils.py +++ b/swift/common/utils.py @@ -1306,6 +1306,8 @@ def urlparse(url): def validate_sync_to(value, allowed_sync_hosts): + if not value: + return None p = urlparse(value) if p.scheme not in ('http', 'https'): return _('Invalid scheme %r in X-Container-Sync-To, must be "http" ' diff --git a/test/unit/common/test_utils.py b/test/unit/common/test_utils.py index 6eaeea0f04..b24484321c 100644 --- a/test/unit/common/test_utils.py +++ b/test/unit/common/test_utils.py @@ -880,7 +880,8 @@ log_name = %(yarr)s''' for goodurl in ('http://1.1.1.1/v1/a/c/o', 'http://1.1.1.1:8080/a/c/o', 'http://2.2.2.2/a/c/o', - 'https://1.1.1.1/v1/a/c/o'): + 'https://1.1.1.1/v1/a/c/o', + ''): self.assertEquals(utils.validate_sync_to(goodurl, ['1.1.1.1', '2.2.2.2']), None)