-
Notifications
You must be signed in to change notification settings - Fork 53
Closed
Description
For instance, the following code doesn't print the full expected content of https://raw.githubusercontent.com/http-rs/surf/6627d9fc15437aea3c0a69e0b620ae7769ea6765/LICENSE-MIT
let url = "https://raw.githubusercontent.com/http-rs/surf/6627d9fc15437aea3c0a69e0b620ae7769ea6765/LICENSE-MIT";
let req = http_types::Request::new(http_types::Method::Get, Url::parse(url).unwrap());
let mut res: http_types::Response = http_client::isahc::IsahcClient::new().send(req).await?;
println!("{}", res.body_string().await?);
The cause of the problem is here:
Lines 51 to 52 in 749e374
let len = body.len().map(|len| len as usize); | |
let body = Body::from_reader(BufReader::new(body), len); |
As specified in https://docs.rs/isahc/0.9.13/isahc/struct.Body.html#method.len :
Since the length may be determined totally separately from the actual bytes, even if a value is returned it should not be relied on as always being accurate, and should be treated as a "hint"
The code shouldn't rely on it to read the response's Body.
Metadata
Metadata
Assignees
Labels
No labels