rust-cookbook icon indicating copy to clipboard operation
rust-cookbook copied to clipboard

redundant code from partial download example in chapter 19.4.3?

Open jsomedon opened this issue 4 years ago • 0 comments
trafficstars

In the code example I see these two lines in the end:

  let content = response.text()?;
  std::io::copy(&mut content.as_bytes(), &mut output_file)?;

Looks like the first line is getting text from response of previous .head() call -- that should be empty string? Then the second line turns that text into bytes then appends to the output_file -- output_file should already contain content of the file to be downloaded, that's done by the for loop above these two lines. So I wonder if these lines are necessary, or am I missing something here?

jsomedon avatar Aug 13 '21 03:08 jsomedon