From 8dca85554f2dedb522e1cb877b415eb36df73dec Mon Sep 17 00:00:00 2001 From: 2235864511 <2235864511@qq.com> Date: Thu, 15 Oct 2026 00:07:57 +0800 Subject: [PATCH] fix(server): reset body flag per request for keep-alive connections On a keep-alive connection the same handler instance serves every request, but setup() only runs once per connection, so _body_read stayed True after the first request and requests #2+ saw an empty body. Reset the flag in handle_one_request() before delegating to the base class. --- loomy2api/server.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/loomy2api/server.py b/loomy2api/server.py index 4e9c1ce..2ba64cc 100644 --- a/loomy2api/server.py +++ b/loomy2api/server.py @@ -119,6 +119,13 @@ class Handler(BaseHTTPRequestHandler): #: Statuses where retrying is pointless (the request itself is wrong). FATAL_REQUEST = (400, 404, 422) + def handle_one_request(self): # noqa: D102 + # On a keep-alive connection the same handler instance serves every + # request; reset the body flag or request #2+ would see an empty + # body (setup() only runs once per connection). + self._body_read = False + super().handle_one_request() + def setup(self): # noqa: D102 super().setup() self._body_read = False