Merge pull request #24350 from ricardoasmarques/wip-json-decode

mgr/dashboard: Check content-type before decode json response

Reviewed-by: Lenz Grimmer <lgrimmer@suse.com>
Reviewed-by: Ricardo Dias <rdias@suse.com>
This commit is contained in:
Ricardo Dias 2018-10-04 10:08:37 +01:00 committed by GitHub
commit 43a72f0e49
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -169,7 +169,8 @@ class DashboardTestCase(MgrTestCase):
else:
assert False
try:
if cls._resp.text and cls._resp.text != "":
content_type = cls._resp.headers['content-type']
if content_type == 'application/json' and cls._resp.text and cls._resp.text != "":
return cls._resp.json()
return cls._resp.text
except ValueError as ex: