Skip to content

Commit 5c43a93

Browse files
committed
determine and transfer the rest response as a json format dynamically
Signed-off-by: archerwen <[email protected]>
1 parent e1b72ab commit 5c43a93

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/redfish/rest/v1.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -950,12 +950,16 @@ def _rest_request(self, path, method='GET', args=None, body=None,
950950
headerstr += '\t' + header[0] + ': ' + header[1] + '\n'
951951

952952
try:
953+
try:
954+
restrespstr = json.dumps(json.loads(restresp.read), indent=4)
955+
except:
956+
restrespstr = restresp.read
953957
LOGGER.debug('HTTP RESPONSE for %s:\nCode: %s\n\nHeaders:\n' \
954958
'%s\nBody Response of %s:\n%s\n'%\
955959
(restresp.request.path,
956960
str(restresp._http_response.status_code)+ ' ' + \
957961
restresp._http_response.reason,
958-
headerstr, restresp.request.path, json.dumps(json.loads(restresp.read), indent=4)))
962+
headerstr, restresp.request.path, restrespstr))
959963
except:
960964
LOGGER.debug('HTTP RESPONSE:\nCode:%s', restresp)
961965
else:

0 commit comments

Comments
 (0)