From fc97bc69775981efa4e22539a2144a17f5cbda1a Mon Sep 17 00:00:00 2001 From: Adam Wilson Date: Wed, 23 Apr 2025 12:28:29 -0600 Subject: [PATCH] echo response back --- tests/api/PathDispatcher.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/tests/api/PathDispatcher.py b/tests/api/PathDispatcher.py index 7e534677f..338e72368 100644 --- a/tests/api/PathDispatcher.py +++ b/tests/api/PathDispatcher.py @@ -5,7 +5,6 @@ import json class PathDispatcher: def __init__(self): self.routes = {} - self.response_headers = [('Content-Type', 'application/json')] def __http_415_notsupported(self, env, start_response): @@ -20,9 +19,15 @@ class PathDispatcher: request_body_size = 0 request_body = env['wsgi.input'].read(request_body_size) - data = json.loads(request_body.decode('utf-8')) - start_response('200 OK', self.response_headers) - return [json.dumps({'received': data}).encode('utf-8')] + request_body = request_body.decode('utf-8') + + # for now, just reading request and echoing back in response + data = json.loads(request_body) + response_body = json.dumps(data).encode('utf-8') + + response_headers = [('Content-Type', 'application/json'), ('Content-Length', str(len(response_body)))] + start_response('200 OK', response_headers) + return [response_body] def __call__(self, env, start_response):