Fix bug internal client's delete_object logs 499
Internal Client's doest not read body for 404. So, When internal deleing object that not existed, proxy-server logs its response code to 499. In this patch, add a code that drain the reponse body to prevent unexpected disconnect in proxy-server Change-Id: I6d170fead798d0d539c69d27a6fa8a2d0123ca99 Closes-Bug: #1835324
This commit is contained in:
@@ -618,7 +618,14 @@ class InternalClient(object):
|
||||
"""
|
||||
|
||||
path = self.make_path(account, container, obj)
|
||||
self.make_request('DELETE', path, (headers or {}), acceptable_statuses)
|
||||
resp = self.make_request('DELETE', path, (headers or {}),
|
||||
acceptable_statuses)
|
||||
|
||||
# Drain the response body to prevent unexpected disconnect
|
||||
# in proxy-server
|
||||
with closing_if_possible(resp.app_iter):
|
||||
for iter_body in resp.app_iter:
|
||||
pass
|
||||
|
||||
def get_object_metadata(
|
||||
self, account, container, obj, metadata_prefix='',
|
||||
|
||||
@@ -1163,28 +1163,17 @@ class TestInternalClient(unittest.TestCase):
|
||||
self.assertEqual(1, client.set_metadata_called)
|
||||
|
||||
def test_delete_object(self):
|
||||
class InternalClient(internal_client.InternalClient):
|
||||
def __init__(self, test, path):
|
||||
self.test = test
|
||||
self.path = path
|
||||
self.make_request_called = 0
|
||||
|
||||
def make_request(
|
||||
self, method, path, headers, acceptable_statuses,
|
||||
body_file=None):
|
||||
self.make_request_called += 1
|
||||
self.test.assertEqual('DELETE', method)
|
||||
self.test.assertEqual(self.path, path)
|
||||
self.test.assertEqual({}, headers)
|
||||
self.test.assertEqual((2, 404), acceptable_statuses)
|
||||
self.test.assertIsNone(body_file)
|
||||
|
||||
account, container, obj = path_parts()
|
||||
path = make_path(account, container, obj)
|
||||
|
||||
client = InternalClient(self, path)
|
||||
path = make_path_info(account, container, obj)
|
||||
client, app = get_client_app()
|
||||
app.register('DELETE', path, swob.HTTPNoContent, {})
|
||||
client.delete_object(account, container, obj)
|
||||
self.assertEqual(1, client.make_request_called)
|
||||
self.assertEqual(app.unclosed_requests, {})
|
||||
self.assertEqual(1, len(app._calls))
|
||||
app.register('DELETE', path, swob.HTTPNotFound, {})
|
||||
client.delete_object(account, container, obj)
|
||||
self.assertEqual(app.unclosed_requests, {})
|
||||
self.assertEqual(2, len(app._calls))
|
||||
|
||||
def test_get_object_metadata(self):
|
||||
account, container, obj = path_parts()
|
||||
|
||||
Reference in New Issue
Block a user