diff --git a/swift/obj/updater.py b/swift/obj/updater.py index 743cf850dc..db38708c4f 100644 --- a/swift/obj/updater.py +++ b/swift/obj/updater.py @@ -29,6 +29,7 @@ from swift.common.ring import Ring from swift.common.utils import get_logger, renamer, write_pickle, \ dump_recon_cache, config_true_value, ismount from swift.common.daemon import Daemon +from swift.common.header_key_dict import HeaderKeyDict from swift.common.storage_policy import split_policy_string, PolicyError from swift.obj.diskfile import get_tmp_dir, ASYNCDIR_BASE from swift.common.http import is_success, HTTP_NOT_FOUND, \ @@ -219,7 +220,7 @@ class ObjectUpdater(Daemon): update['account'], update['container']) obj = '/%s/%s/%s' % \ (update['account'], update['container'], update['obj']) - headers_out = update['headers'].copy() + headers_out = HeaderKeyDict(update['headers']) headers_out['user-agent'] = 'object-updater %s' % os.getpid() headers_out.setdefault('X-Backend-Storage-Policy-Index', str(int(policy))) diff --git a/test/unit/obj/test_server.py b/test/unit/obj/test_server.py index 7d03c82c63..116c5d84cc 100644 --- a/test/unit/obj/test_server.py +++ b/test/unit/obj/test_server.py @@ -1019,8 +1019,8 @@ class TestObjectController(unittest.TestCase): self.assertEqual((node, 99, 'PUT', '/a/c/o'), mock_update.call_args_list[0][0][0:4]) actual_headers = mock_update.call_args_list[0][0][4] - self.assertTrue( - actual_headers.pop('user-agent').startswith('object-updater')) + # User-Agent is updated. + expected_post_headers['User-Agent'] = 'object-updater %s' % os.getpid() self.assertDictEqual(expected_post_headers, actual_headers) self.assertFalse( os.listdir(os.path.join(