From b173995666b026def3f6558d9a8c972b75449323 Mon Sep 17 00:00:00 2001 From: Kota Tsuyuzaki Date: Thu, 4 Feb 2016 05:18:42 -0800 Subject: [PATCH] Fix missing Accept-Ranges Since commit 4f2ed8bcd0468f3b69d5fded274d8d6b02ac3d10, the response header for GET EC object doesn't include the Accept-Ranges header. This patch fixes it and also adds a few unittests to prevent regression. Closes-Bug: #1542168 Change-Id: Ibafe56ac87b14bc0028953e620a653cd68dd3f84 --- swift/proxy/controllers/obj.py | 1 + test/unit/proxy/controllers/test_obj.py | 3 +++ 2 files changed, 4 insertions(+) diff --git a/swift/proxy/controllers/obj.py b/swift/proxy/controllers/obj.py index 1a0d1f187a..f09bcbd23c 100644 --- a/swift/proxy/controllers/obj.py +++ b/swift/proxy/controllers/obj.py @@ -2057,6 +2057,7 @@ class ECObjectController(BaseObjectController): headers=resp_headers, conditional_response=True, app_iter=app_iter) + resp.accept_ranges = 'bytes' app_iter.kickoff(req, resp) else: statuses = [] diff --git a/test/unit/proxy/controllers/test_obj.py b/test/unit/proxy/controllers/test_obj.py index 655bf07700..fcab9ad9e0 100755 --- a/test/unit/proxy/controllers/test_obj.py +++ b/test/unit/proxy/controllers/test_obj.py @@ -390,6 +390,7 @@ class BaseObjectControllerMixin(object): with set_http_connect(200): resp = req.get_response(self.app) self.assertEqual(resp.status_int, 200) + self.assertIn('Accept-Ranges', resp.headers) def test_HEAD_x_newest(self): req = swift.common.swob.Request.blank('/v1/a/c/o', method='HEAD', @@ -693,6 +694,7 @@ class TestReplicatedObjController(BaseObjectControllerMixin, with set_http_connect(200): resp = req.get_response(self.app) self.assertEqual(resp.status_int, 200) + self.assertIn('Accept-Ranges', resp.headers) def test_GET_error(self): req = swift.common.swob.Request.blank('/v1/a/c/o') @@ -1173,6 +1175,7 @@ class TestECObjController(BaseObjectControllerMixin, unittest.TestCase): with set_http_connect(*get_resp): resp = req.get_response(self.app) self.assertEqual(resp.status_int, 200) + self.assertIn('Accept-Ranges', resp.headers) def test_GET_simple_x_newest(self): req = swift.common.swob.Request.blank('/v1/a/c/o',