stable-diffusion.cpp/examples
Claude 8b6acc9316
fix(server): answer a cancel request without waiting for a body
A plain cpp-httplib handler runs only after the library has read the body
of the request. For a POST with neither Content-Length nor chunked
encoding, which is what `curl -X POST <url>` sends, the library cannot know
that there is no body and waits for its read timeout of 5 seconds first.
The cancel route has no body, so stopping a job from the command line took
5 seconds longer than it should (15 s with the default wait, 5 s with
?wait=0).

The route now takes the body through a content reader, which is called
without reading anything first, and drains the body only when the request
announces one with Content-Length or Transfer-Encoding. The API key check
still runs before the route, as for every other route.

Measured on a real sd-server: `curl -X POST .../cancel` went from 5.1 s to
under a millisecond; a JSON body, a chunked body and a 2 MB body are still
accepted and ignored. The other POST routes of the server all need a JSON
body, so none of them is affected.

Claude-Session: https://claude.ai/code/session_01EhZzDBkuuMp1jBf4WtEySC
2026-10-14 22:15:52 +02:00
..
cli feat: add --profile to choose a resource footprint 2026-10-11 07:19:14 +02:00
common feat: let --profile auto count the memory of several GPUs 2026-10-14 01:03:42 +02:00
server fix(server): answer a cancel request without waiting for a body 2026-10-14 22:15:52 +02:00
CMakeLists.txt feat: add Mage-Flow support (#1808) 2026-07-23 01:23:25 +08:00