From d859615e456d14d371ea55bf092f3c1e97d174b7 Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Thu, 3 Apr 2014 16:55:23 -0400 Subject: [PATCH] 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. --- confluent/httpapi.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/confluent/httpapi.py b/confluent/httpapi.py index bd0e1376..93e6bce6 100644 --- a/confluent/httpapi.py +++ b/confluent/httpapi.py @@ -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'})