From 83db40da51a9646acb6e1c0b8e4dfe0d4298d135 Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Fri, 13 Sep 2013 11:45:17 -0400 Subject: [PATCH] Implement urlencoded form data for the data into the console interface --- confluent/httpapi.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/confluent/httpapi.py b/confluent/httpapi.py index b8e3d7b6..5a2da740 100644 --- a/confluent/httpapi.py +++ b/confluent/httpapi.py @@ -25,8 +25,9 @@ def _get_query_dict(qstring, reqbody, reqtype): qdict[qkey] = qvalue if reqbody is not None: if "application/x-www-form-urlencoded" in reqtype: - print reqbody - raise(Exception("TODO: must actually do url form encode parse here")) + pbody = urlparse.parse_qs(reqbody) + for ky in pbody.iterkeys(): + qdict[ky] = pbody[ky][0] return qdict @@ -132,8 +133,9 @@ def resourcehandler(env, start_response): 'application/json; charset=utf-8')]) return # client has requests to send or receive, not both... else: #no keys, but a session, means it's hooking to receive data - outdata = consolesessions[sessid].get_next_output(timeout=45) - json = '{"session":"%s","data":"%s"}'%(querydict['session'], + sessid = querydict['session'] + outdata = consolesessions[sessid].get_next_output(timeout=45) + json = '{"session":"%s","data":"%s"}'%(querydict['session'], outdata) start_response('404 Not Found', []) return ["Unrecognized directive (404)"]