Skip to content

Commit

Permalink
an http request should return bytes
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
hanstrompert committed Nov 12, 2021
1 parent 69d04b0 commit 241daf9
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions opennsa/shared/modifiableresource.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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

Expand Down

0 comments on commit 241daf9

Please sign in to comment.