Actix-Web: Extracting the response text or bytes from a ResponseBody<Body>

How can I extract the bytes or response text from a Actix http Response.
I have a Response and can take the Body via take_body but how can I transform that body into bytes so I can analyze or use it?

You need to use the Stream impl on Response.

use tokio::stream::StreamExt;

let mut body_vec = Vec::new();
while let Some(chunk) = {

// entire body is in `body_vec` now

It's possible that there are also other solutions.

1 Like

Thank you!

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.