From 3a44e48e4be912d66c2f634a0e4d1a33132b15b6 Mon Sep 17 00:00:00 2001 From: Roberto Hueso Gómez Date: Thu, 16 Jan 2020 11:48:57 +0100 Subject: Adapt client responses to the server's Header parameters need to be sorted for the test server. --- src/ogRest.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/ogRest.py b/src/ogRest.py index 7d9120f..dcc0817 100644 --- a/src/ogRest.py +++ b/src/ogRest.py @@ -24,7 +24,7 @@ class restResponse(): def getResponse(response, jsonResp=None): msg = '' if response == ogResponses.BAD_REQUEST: - msg = 'HTTP/1.0 400 Bad request' + msg = 'HTTP/1.0 400 Bad Request' elif response == ogResponses.IN_PROGRESS: msg = 'HTTP/1.0 202 Accepted' elif response == ogResponses.OK: @@ -34,12 +34,15 @@ class restResponse(): else: return msg - if not jsonResp == None: - msg = msg + '\nContent-Type:application/json' - msg = msg + '\nContent-Length:' + str(len(jsonResp.dumpMsg())) - msg = msg + '\n' + jsonResp.dumpMsg() + msg += '\r\n' + + if jsonResp: + msg += 'Content-Length:' + str(len(jsonResp.dumpMsg())) + msg += '\r\nContent-Type:application/json' + msg += '\r\n\r\n' + jsonResp.dumpMsg() + else: + msg += '\r\n' - msg = msg + '\r\n\r\n' return msg class ogThread(): -- cgit v1.2.3-18-g5258