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

Fix for HTTP API browser

Python 3 had data coming in as bytes.
This commit is contained in:
Jarrod Johnson 2020-08-27 13:11:21 -04:00
parent bf1019c497
commit e8eaddf375
2 changed files with 6 additions and 0 deletions

View File

@ -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

View File

@ -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]