Skip to content

Commit

Permalink
add into_vec
Browse files Browse the repository at this point in the history
  • Loading branch information
orion GONZALEZ (contractor) committed Aug 21, 2023
1 parent 50fd1fe commit 1bec934
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/response.rs
Original file line number Diff line number Diff line change
Expand Up @@ -481,6 +481,17 @@ impl Response {
}
}

pub fn into_vec(self) -> Result<Vec<u8>, Error> {
let size = self
.header("Content-Type")
.unwrap_or_default()
.parse::<usize>()
.unwrap_or_default();
let mut buf = Vec::with_capacity(size);
self.into_reader().read_to_end(&mut buf)?;
Ok(buf)
}

/// Read the body of this response into a serde_json::Value, or any other type that
/// implements the [serde::Deserialize] trait.
///
Expand Down

0 comments on commit 1bec934

Please sign in to comment.