Archived
Eighteen upstream releases, taken the way the lift was taken: the split pair llama.cpp now carries (1ab23c33b), against the cpp-httplib v0.64.0 tag. The vendored pair before this commit was byte-identical to the old base plus patch 0022 -- re-checked against the pinned lift commit, not taken on faith. 0022 was written because upstream's keep-alive drain could be paced one byte per socket timeout forever, and because a refused request's unread body had no reason to be drained at all. v0.64.0 does both of those itself: every 4xx/5xx response now carries Connection: close, a scope_exit in write_response closes the socket when it sees that option, the drain is skipped for any response committed to close, and a drain that does run is bounded by a 256 KB cap, the connection's read timeout as a total, and an immediate close for a part-read body. The old patch applied nowhere, and mostly needed to be nothing. What one line is still owed: the library bounds the drain's time only by the connection's read timeout -- the same knob that bounds a whole request's reads, uploads included, so lowering it would cap uploads too. The reworked patch gives the drain a five-second budget of its own. transport_test's cases for the refusal and the stalled drain are unchanged: they pin the behavior, whoever in the tree implements it. Also new in this window and watched with interest: set_trusted_proxies arrives with real IP matching -- the seam a coming commit wires. Manifest regenerated; vendor_sums green.
23 lines
1.1 KiB
Diff
23 lines
1.1 KiB
Diff
diff --git a/httplib.cpp b/httplib.cpp
|
|
index ebe01d1..e5efe4d 100644
|
|
--- a/httplib.cpp
|
|
+++ b/httplib.cpp
|
|
@@ -10585,7 +10585,16 @@ Server::process_request(Stream &strm, const std::string &remote_addr,
|
|
// arrive within the read timeout.
|
|
if (!req.body_consumed_ && detail::has_framed_body(req) &&
|
|
!detail::has_header_token(res.headers, "Connection", "close")) {
|
|
- strm.set_max_timeout(read_timeout_msec);
|
|
+ // LOCAL CHANGE (radiance): the drain's budget is the lesser of five
|
|
+ // seconds and the connection's read timeout. read_timeout_msec bounds a
|
|
+ // whole request's reads -- uploads included -- so it cannot itself be
|
|
+ // lowered to hurry a drain along; without its own budget, a client
|
|
+ // dribbling one byte per gap paces this worker for the connection's
|
|
+ // full timeout after the response was already sent.
|
|
+ constexpr int kDrainBudgetMsec = 5000;
|
|
+ strm.set_max_timeout(read_timeout_msec < kDrainBudgetMsec
|
|
+ ? read_timeout_msec
|
|
+ : kDrainBudgetMsec);
|
|
int dummy_status;
|
|
if (req.body_read_started_ ||
|
|
!detail::read_content(
|