Browse Source

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.
rust-volume-server
Chris Lu 4 days ago
parent
commit
e852ba75cb
  1. 4
      seaweed-volume/src/server/handlers.rs

4
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 {

Loading…
Cancel
Save