From daf28dde7c20f644ac612cbc6d3d85f152f848ad Mon Sep 17 00:00:00 2001 From: Doug Weimer Date: Tue, 30 Aug 2011 08:11:26 -0700 Subject: [PATCH 1/2] Changed GETorHEAD_base to return an object even when HTTP_X_NEWEST is set and none of the requested objects have a timestamp set. --- swift/proxy/server.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/swift/proxy/server.py b/swift/proxy/server.py index 1099030577..7d7ee49d7e 100644 --- a/swift/proxy/server.py +++ b/swift/proxy/server.py @@ -645,13 +645,14 @@ class Controller(object): possible_source.status in (200, 206)) or \ 200 <= possible_source.status <= 399: if newest: - ts = 0 if source: ts = float(source.getheader('x-put-timestamp') or source.getheader('x-timestamp') or 0) - pts = float(possible_source.getheader('x-put-timestamp') or - possible_source.getheader('x-timestamp') or 0) - if pts > ts: + pts = float(possible_source.getheader('x-put-timestamp') or + possible_source.getheader('x-timestamp') or 0) + if pts > ts: + source = possible_source + else: source = possible_source continue else: From 5b9137cc716a45325253ad233e96a64f716ce554 Mon Sep 17 00:00:00 2001 From: gholt Date: Tue, 30 Aug 2011 20:27:06 +0000 Subject: [PATCH 2/2] Test for x-newest with new proxy and old object server --- test/unit/proxy/test_server.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/test/unit/proxy/test_server.py b/test/unit/proxy/test_server.py index 14924f194b..8a1888dabc 100644 --- a/test/unit/proxy/test_server.py +++ b/test/unit/proxy/test_server.py @@ -182,6 +182,8 @@ def fake_http_connect(*code_iter, **kwargs): self.etag or '"68b329da9893e34099c7d8ad5cb9c940"', 'x-works': 'yes', } + if not self.timestamp: + del headers['x-timestamp'] try: if container_ts_iter.next() is False: headers['x-container-timestamp'] = '1' @@ -1079,6 +1081,7 @@ class TestObjectController(unittest.TestCase): test_status_map((200, 200, 200), 200, ('1', '3', '2'), '3') test_status_map((200, 200, 200), 200, ('1', '3', '1'), '3') test_status_map((200, 200, 200), 200, ('3', '3', '1'), '3') + test_status_map((200, 200, 200), 200, (None, None, None), None) def test_GET_newest(self): with save_globals():