From 241daf9f4f7aaf073905bd3235967bf0ad0541d8 Mon Sep 17 00:00:00 2001 From: Hans Trompert Date: Fri, 12 Nov 2021 10:20:40 +0100 Subject: [PATCH] an http request should return bytes This solves the '500 - Request did not return bytes', that is now returned instaed of a 304 Not Modified, while trying to fetch a discovery or topology file that is older than the If-Modified-Since header. --- opennsa/shared/modifiableresource.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/opennsa/shared/modifiableresource.py b/opennsa/shared/modifiableresource.py index 436758b7..95a6b964 100644 --- a/opennsa/shared/modifiableresource.py +++ b/opennsa/shared/modifiableresource.py @@ -46,7 +46,7 @@ def render_GET(self, request): if self.representation is None: # we haven't been given a representation yet request.setResponseCode(500) - return 'Resource has not yet been created/updated.' + return b'Resource has not yet been created/updated.' # check for if-modified-since header, and send 304 back if it is not been modified msd_header = request.getHeader(IF_MODIFIED_SINCE) @@ -55,7 +55,7 @@ def render_GET(self, request): msd = datetime.datetime.strptime(msd_header, RFC850_FORMAT) if msd >= self.last_update_time: request.setResponseCode(304) - return '' + return b'' except ValueError: pass # error parsing timestamp