From 8a8ea8f22a2b01ccfdddda5ecf20a5237093280b Mon Sep 17 00:00:00 2001 From: John Dickinson Date: Fri, 9 Nov 2012 14:39:39 -0800 Subject: [PATCH] fix error with setting max age and incorrect tests Change-Id: I3f0db3b70ea5df323597b556682c2d1fb28afe53 --- swift/proxy/controllers/base.py | 4 ++-- test/unit/proxy/test_server.py | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/swift/proxy/controllers/base.py b/swift/proxy/controllers/base.py index d406540dc7..200e9682ff 100644 --- a/swift/proxy/controllers/base.py +++ b/swift/proxy/controllers/base.py @@ -728,8 +728,8 @@ class Controller(object): resp.status = HTTP_UNAUTHORIZED return resp # CORS preflight request that isn't valid headers['access-control-allow-origin'] = req_origin_value - if cors.get('max_age', None) is not None: - headers['access-control-max-age'] = '%d' % cors.get('max_age') + if cors.get('max_age') is not None: + headers['access-control-max-age'] = cors.get('max_age') headers['access-control-allow-methods'] = ', '.join( self.allowed_methods) if cors.get('allow_headers'): diff --git a/test/unit/proxy/test_server.py b/test/unit/proxy/test_server.py index 6e05364735..089ce46859 100755 --- a/test/unit/proxy/test_server.py +++ b/test/unit/proxy/test_server.py @@ -3535,7 +3535,7 @@ class TestObjectController(unittest.TestCase): 'cors': { 'allow_origin': 'http://foo.bar:8080 https://foo.bar', 'allow_headers': 'x-foo', - 'max_age': 999, + 'max_age': '999', } } controller.container_info = my_container_info @@ -3595,7 +3595,7 @@ class TestObjectController(unittest.TestCase): 'cors': { 'allow_origin': '*', 'allow_headers': 'x-foo', - 'max_age': 999, + 'max_age': '999', } } controller.container_info = my_container_info_wildcard @@ -4141,7 +4141,7 @@ class TestContainerController(unittest.TestCase): 'cors': { 'allow_origin': 'http://foo.bar:8080 https://foo.bar', 'allow_headers': 'x-foo', - 'max_age': 999, + 'max_age': '999', } } controller.container_info = my_container_info @@ -4202,7 +4202,7 @@ class TestContainerController(unittest.TestCase): 'cors': { 'allow_origin': '*', 'allow_headers': 'x-foo', - 'max_age': 999, + 'max_age': '999', } } controller.container_info = my_container_info_wildcard