From fb30f7cc7788edfb303b42a7dc45c4964485412c Mon Sep 17 00:00:00 2001 From: Sean McArthur Date: Tue, 6 Aug 2024 10:22:25 -0400 Subject: [PATCH] decompression: propagate size_hint when body is identity --- tower-http/src/decompression/body.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/tower-http/src/decompression/body.rs b/tower-http/src/decompression/body.rs index 88197bbf..9378e5ca 100644 --- a/tower-http/src/decompression/body.rs +++ b/tower-http/src/decompression/body.rs @@ -15,7 +15,7 @@ use async_compression::tokio::bufread::ZlibDecoder; use async_compression::tokio::bufread::ZstdDecoder; use bytes::{Buf, Bytes}; use http::HeaderMap; -use http_body::Body; +use http_body::{Body, SizeHint}; use pin_project_lite::pin_project; use std::task::Context; use std::{ @@ -326,6 +326,13 @@ where BodyInnerProj::Zstd { inner } => match inner.0 {}, } } + + fn size_hint(&self) -> SizeHint { + match self.inner { + BodyInner::Identity { ref inner } => inner.size_hint(), + _ => SizeHint::default(), + } + } } #[cfg(feature = "decompression-gzip")]