pub fn idle_timeout_body(
body: BoxBody<Bytes, Box<dyn Error + Send + Sync>>,
idle: Duration,
) -> BoxBody<Bytes, Box<dyn Error + Send + Sync>>Expand description
Wraps body so it errors when no frame arrives for idle. The timer
resets on every frame, so a steady stream survives indefinitely while a
silent one is reaped — and reaped as a real failure
(Poll::Ready(Some(Err(IdleTimeoutError)))), not a clean end: ending
cleanly would write the chunked terminator (HTTP/1.1) or END_STREAM
(h2) exactly as a legitimately complete response would, making a
truncated body indistinguishable from a complete one on the wire — on
exactly the unbounded bodies (NDJSON exports, log tails, bulk proxied
data) this feature targets. A real upstream error — the wrapped body
itself yielding Err, e.g. a connection reset — is forwarded unchanged;
the reap only fires when nothing else has.