From e852ba75cbdbc792ce830c5f4b42813f65c17e80 Mon Sep 17 00:00:00 2001 From: Chris Lu Date: Tue, 17 Mar 2026 22:45:56 -0700 Subject: [PATCH] Add size_hint to TrackedBody so throttled downloads get Content-Length TrackedBody (used for download throttling) did not implement size_hint(), causing HTTP/1.1 to fall back to chunked transfer encoding instead of setting Content-Length. Go always sets Content-Length explicitly for non-range responses. --- seaweed-volume/src/server/handlers.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/seaweed-volume/src/server/handlers.rs b/seaweed-volume/src/server/handlers.rs index 06e87a678..e4d849bf4 100644 --- a/seaweed-volume/src/server/handlers.rs +++ b/seaweed-volume/src/server/handlers.rs @@ -61,6 +61,10 @@ impl http_body::Body for TrackedBody { let data = std::mem::take(&mut self.data); std::task::Poll::Ready(Some(Ok(http_body::Frame::data(bytes::Bytes::from(data))))) } + + fn size_hint(&self) -> http_body::SizeHint { + http_body::SizeHint::with_exact(self.data.len() as u64) + } } impl Drop for TrackedBody {