Skip to content

Commit f614334

Browse files
committed
fix: Python handle_refresh error paths suppress body on HEAD
1 parent c83cf54 commit f614334

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

server.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -408,15 +408,21 @@ def handle_refresh(self, head_only=False):
408408
if not head_only:
409409
self.wfile.write(body)
410410
except FileNotFoundError:
411+
body = json.dumps({"error": "data.json not found"}).encode()
411412
self.send_response(503)
412413
self.send_header("Content-Type", "application/json")
414+
self.send_header("Content-Length", str(len(body)))
413415
self.end_headers()
414-
self.wfile.write(json.dumps({"error": "data.json not found"}).encode())
416+
if not head_only:
417+
self.wfile.write(body)
415418
except Exception as e:
419+
body = json.dumps({"error": str(e)}).encode()
416420
self.send_response(500)
417421
self.send_header("Content-Type", "application/json")
422+
self.send_header("Content-Length", str(len(body)))
418423
self.end_headers()
419-
self.wfile.write(json.dumps({"error": str(e)}).encode())
424+
if not head_only:
425+
self.wfile.write(body)
420426

421427
_MAX_BODY = 64 * 1024 # 64 KB request body limit
422428
_MAX_QUESTION = 2000 # max question length in chars

0 commit comments

Comments
 (0)