Remove duplicated 'User-Agent' header from object-updater's requests
When Object-Server saves async-update in pickle files, 'User-Agent: object-server %(pid)' (the key is title style) is included in the pickles. However, Object-Updater will add 'user-agent: object-updater %(pid)' (the key is lower case style) to the pickled headers and use it to make http connection. According to RFC 7230, each header field consists of a case-insensitive field name, therefore either of 'User-Agent' and 'user-agent' should not be included in the headers. This patch removes old 'User-Agent' header from object-updater's requests. Change-Id: Ia624558395584457c718b311fe80e1a8406e22ad Closes-Bug:#1635114
This commit is contained in:
parent
ebcc3ac8fa
commit
e166e19b23
@ -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)))
|
||||
|
@ -1016,8 +1016,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(
|
||||
|
Loading…
x
Reference in New Issue
Block a user