We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 372e366 commit 737308fCopy full SHA for 737308f
examples/http_get.rs
@@ -17,10 +17,8 @@ async fn main() -> Result<(), Box<dyn Error>> {
17
.ok_or_else(|| "response expected to have Content-Type header")?;
18
assert_eq!(content_type, "application/json; charset=utf-8");
19
20
- // Would much prefer read_to_end here:
21
- let mut body_buf = vec![0; 4096];
22
- let body_len = response.body().read(&mut body_buf).await?;
23
- body_buf.truncate(body_len);
+ let mut body_buf = Vec::new();
+ let _body_len = response.body().read_to_end(&mut body_buf).await?;
24
25
let val: serde_json::Value = serde_json::from_slice(&body_buf)?;
26
let body_url = val
0 commit comments