From 8ee3630aa1bd330bd133863689a53641a7887db6 Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Mon, 15 Nov 2021 16:09:17 -0500 Subject: [PATCH] Simplify get_nonce Use the helper function, for example to cope with the prospect of gzip response. --- confluent_server/confluent/discovery/handlers/xcc.py | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/confluent_server/confluent/discovery/handlers/xcc.py b/confluent_server/confluent/discovery/handlers/xcc.py index 2ecb9d9f..872856f6 100644 --- a/confluent_server/confluent/discovery/handlers/xcc.py +++ b/confluent_server/confluent/discovery/handlers/xcc.py @@ -148,12 +148,8 @@ class NodeHandler(immhandler.NodeHandler): }) headers = {'Connection': 'keep-alive', 'Content-Type': 'application/json'} - nonce = None - wc.request('POST', '/api/providers/get_nonce', '{}') - rsp = wc.getresponse() - tokbody = rsp.read() - if rsp.status == 200: - rsp = json.loads(tokbody) + rsp, status = wc.grab_json_response_with_status('/api/providers/get_nonce', {}) + if status == 200: nonce = rsp.get('nonce', None) headers['Content-Security-Policy'] = 'nonce={0}'.format(nonce) wc.request('POST', '/api/login', adata, headers)