mirror of
https://github.com/leejet/stable-diffusion.cpp.git
synced 2026-11-28 19:16:33 +00:00
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 |
||
|---|---|---|
| .. | ||
| cli | ||
| common | ||
| server | ||
| CMakeLists.txt | ||