Skip to content

How to fetch bytes from GET response #300

Answered by sagebind
meghashyam6 asked this question in Questions
Discussion options

You must be logged in to vote

The response Body implements Read, so you can simply use the normal methods provided by the standard library to read the stream into a buffer:

let mut response = isahc::get("http://example.org")?;
let mut bytes = Vec::new();

// Read the whole response into memory.
response.body_mut().read_to_end(&mut bytes)?;

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@meghashyam6
Comment options

Answer selected by sagebind
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #299 on February 08, 2021 03:20.