From e8eaddf37541630622b232449dd1a6ffe78ec991 Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Thu, 27 Aug 2020 13:11:21 -0400 Subject: [PATCH] Fix for HTTP API browser Python 3 had data coming in as bytes. --- confluent_server/confluent/config/configmanager.py | 2 ++ confluent_server/confluent/httpapi.py | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/confluent_server/confluent/config/configmanager.py b/confluent_server/confluent/config/configmanager.py index d83cd4be..7313a1c3 100644 --- a/confluent_server/confluent/config/configmanager.py +++ b/confluent_server/confluent/config/configmanager.py @@ -117,6 +117,8 @@ _validroles = ('Administrator', 'Operator', 'Monitor') def attrib_supports_expression(attrib): + if not isinstance(attrib, str): + attrib = attrib.decode('utf8') attrib = _attraliases.get(attrib, attrib) if attrib.startswith('secret.') or attrib.startswith('crypted.'): return False diff --git a/confluent_server/confluent/httpapi.py b/confluent_server/confluent/httpapi.py index 07665e86..a8d96329 100644 --- a/confluent_server/confluent/httpapi.py +++ b/confluent_server/confluent/httpapi.py @@ -182,6 +182,8 @@ def _get_query_dict(env, reqbody, reqtype): qdict[qkey] = qvalue if reqbody is not None: if "application/x-www-form-urlencoded" in reqtype: + if not isinstance(reqbody, str): + reqbody = reqbody.decode('utf8') pbody = urlparse.parse_qs(reqbody, True) for ky in pbody: if len(pbody[ky]) > 1: # e.g. REST explorer @@ -190,6 +192,8 @@ def _get_query_dict(env, reqbody, reqtype): else: qdict[ky] = pbody[ky][0] elif 'application/json' in reqtype: + if not isinstance(reqbody, str): + reqbody = reqbody.decode('utf8') pbody = json.loads(reqbody) for key in pbody: qdict[key] = pbody[key]