Repository: seanmonstar/reqwest (language: rust)

Issue:
None content_length in v0.12.2 when using timeout
With version  v0.12.2 content_length returns `None` when using timeout, works in v0.11.27

```sh
 cargo run
   Compiling reqwest v0.11.27
   Compiling no-content-length v0.1.0 (/my_dir)
    Finished dev [unoptimized + debuginfo] target(s) in 3.48s
     Running `target/debug/no-content-length`
----------> content_length: Some(3501)

$ cargo run
   Compiling reqwest v0.12.2
   Compiling no-content-length v0.1.0 (/my_dir)
    Finished dev [unoptimized + debuginfo] target(s) in 3.40s
     Running `target/debug/no-content-length`
----------> content_length: None
```

```rust
use std::time::Duration;

use reqwest::Result;

const URL: &str =
    "https://www.google.com/images/branding/googlelogo/1x/googlelogo_light_color_272x92dp.png";

#[tokio::main]
async fn main() -> Result<()> {
    let c = reqwest::Client::builder().build()?;
    let resp = c.get(URL).timeout(Duration::from_secs(1)).send().await?;
    println!("----------> content_length: {:?}", resp.content_length());
    Ok(())
}

```

```toml
[package]
name = "no-content-length"
version = "0.1.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
tokio = { version = "1", features = ["full"] }
reqwest = { version = "0.12" }

``` 


Discussion / hints:

Fix patch:
diff --git a/src/async_impl/body.rs b/src/async_impl/body.rs
index 3ba9350de..cd9658c64 100644
--- a/src/async_impl/body.rs
+++ b/src/async_impl/body.rs
@@ -309,6 +309,16 @@ where
                 .map(|opt_chunk| opt_chunk.map_err(crate::error::body)),
         )
     }
+
+    #[inline]
+    fn size_hint(&self) -> http_body::SizeHint {
+        self.inner.size_hint()
+    }
+
+    #[inline]
+    fn is_end_stream(&self) -> bool {
+        self.inner.is_end_stream()
+    }
 }
 
 pub(crate) type ResponseBody =


Test patch:
diff --git a/tests/timeouts.rs b/tests/timeouts.rs
index ee690933e..5ba687337 100644
--- a/tests/timeouts.rs
+++ b/tests/timeouts.rs
@@ -303,3 +303,23 @@ fn write_timeout_large_body() {
     assert!(err.is_timeout());
     assert_eq!(err.url().map(|u| u.as_str()), Some(url.as_str()));
 }
+
+#[tokio::test]
+async fn response_body_timeout_forwards_size_hint() {
+    let _ = env_logger::try_init();
+
+    let server = server::http(move |_req| async { http::Response::new(b"hello".to_vec().into()) });
+
+    let client = reqwest::Client::new();
+
+    let url = format!("http://{}/slow", server.addr());
+
+    let res = client
+        .get(&url)
+        .timeout(Duration::from_secs(1))
+        .send()
+        .await
+        .expect("response");
+
+    assert_eq!(res.content_length(), Some(5));
+}