Merge "Don't decode empty response body"

This commit is contained in:
Jenkins 2017-04-16 11:41:09 +00:00 committed by Gerrit Code Review
commit 15889916da
2 changed files with 7 additions and 1 deletions

View File

@ -816,6 +816,11 @@ class ClientV2TestJson(CLITestV20Base):
self.mox.VerifyAll()
self.mox.UnsetStubs()
def test_deserialize_without_data(self):
data = u''
result = self.client.deserialize(data, 200)
self.assertEqual(data, result)
class CLITestV20ExceptionHandler(CLITestV20Base):

View File

@ -312,7 +312,8 @@ class ClientBase(object):
def deserialize(self, data, status_code):
"""Deserializes a JSON string into a dictionary."""
if status_code == 204:
# TODO(hichihara): Remove checking 204 in bug 1611167
if status_code == 204 or not data:
return data
return serializer.Serializer().deserialize(
data)['body']