2
0
mirror of https://github.com/xcat2/confluent.git synced 2024-11-22 01:22:00 +00:00

Change http console replies to not always put things under 'data'.

To resemble more strongly the socket api, have the HTTP response resemble
a normal reply more closely.
This commit is contained in:
Jarrod Johnson 2014-04-03 16:55:23 -04:00
parent e2e2d884b7
commit d859615e45

View File

@ -280,12 +280,16 @@ def resourcehandler(env, start_response):
consolesessions[sessid]['expiry'] = time.time() + 90
outdata = consolesessions[sessid]['session'].get_next_output(
timeout=45)
if isinstance(outdata, dict):
rspdata = outdata
rspdata['session'] = querydict['session']
else:
rspdata = {'session': querydict['session'],
'data': outdata}
try:
rsp = json.dumps({'session': querydict['session'],
'data': outdata})
rsp = json.dumps(rspdata)
except UnicodeDecodeError:
rsp = json.dumps({'session': querydict['session'],
'data': outdata}, encoding='cp437')
rsp = json.dumps(rspdata, encoding='cp437')
except UnicodeDecodeError:
rsp = json.dumps({'session': querydict['session'],
'data': 'DECODEERROR'})