From 1bec934e4210c41c7ad3aa14597e6fe51ad9f905 Mon Sep 17 00:00:00 2001 From: "orion GONZALEZ (contractor)" Date: Mon, 21 Aug 2023 18:18:12 +0200 Subject: [PATCH] add into_vec --- src/response.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/response.rs b/src/response.rs index 2f56cc9d..fb88d5ef 100644 --- a/src/response.rs +++ b/src/response.rs @@ -481,6 +481,17 @@ impl Response { } } + pub fn into_vec(self) -> Result, Error> { + let size = self + .header("Content-Type") + .unwrap_or_default() + .parse::() + .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. ///