Merge "Remove duplicated 'User-Agent' header from object-updater's requests"

This commit is contained in:
Jenkins 2016-11-16 21:50:21 +00:00 committed by Gerrit Code Review
commit 98a635b242
2 changed files with 4 additions and 3 deletions

View File

@ -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)))

View File

@ -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(