Skip to content

Qwen3.8-Flash-Next on any consumer hardware: one-click install for Windows / Linux. Strata inference engine, OpenAI/Anthropic API on localhost, optional image input.

C++

serve: /config and /load bodies are marked read, so the close does not wait for the drain (#594)

Niko1221da170f8ae7c3
diff --git a/serve/server.py b/serve/server.py
index 62305b1e3..b8067f15c 100644
--- a/serve/server.py
+++ b/serve/server.py
@@ -3435,6 +3435,7 @@ def make_handler(svc: Service):
complete = False
finally:
self.connection.settimeout(timeout)
+ self.body_read = True # nothing left for the drain to wait for (#594)
if not complete:
self._json(400, {"error": {"message": "incomplete control request body"}})
return complete
@@ -3465,7 +3466,7 @@ def make_handler(svc: Service):
def _config_post(self):
"""#564: change a few documented keys of the run config - JSON from Strata's own page only, as
/settings (the key is checked before); every other key of the file stays as it is."""
- body = self.rfile.read(int(self.headers.get("Content-Length", 0)))
+ body = self._body()
if not self._own_page("the run config can be changed"):
return
if not svc.config_path:
diff --git a/serve/test_server.py b/serve/test_server.py
index f5c1d445e..f1d70a285 100644
--- a/serve/test_server.py
+++ b/serve/test_server.py
@@ -3090,6 +3090,14 @@ class AnswerBeforeTheBody(unittest.TestCase):
def test_not_the_apps_own_page(self):
self.assertEqual(self.status("POST", "/load", {"Origin": "https://example.com"}), "HTTP/1.0 403 Forbidden")
+ def test_a_body_a_handler_read_is_not_waited_for(self):
+ """#594: /config and /load read their body themselves: the close must not wait for the drain's 5 s."""
+ for path in ("/config", "/load", "/unload"):
+ with self.subTest(path=path):
+ t0 = time.monotonic()
+ self.status("POST", path)
+ self.assertLess(time.monotonic() - t0, 1.5) # the status() helper itself pauses 0.5 s
+
def test_a_host_the_server_does_not_answer_to(self):
self.assertEqual(self.status("POST", "/v1/chat/completions", {"Host": "rebind.example.com"}),
"HTTP/1.0 403 Forbidden")