A Body is a stream of bytes, and the whole response is typically not loaded into memory at once. You must read the entire response into memory if you want to go through it twice.
Note that your tx.send_data(buffer).await? might deadlock as nothing is reading from the channel. To convert a Bytes into a Body, just do Body::from(buffer).
Your use of Bytes::copy_from_slice(whole_body.bytes()) is actually incorrect. From the documentation of Buf::bytes, see:
Note that this can return shorter slice (this allows non-continuous internal representation).
And the impl Buf returned by aggregate does in fact make use of this feature. I would do it like this:
use hyper::body::HttpBody;
let buffer: Bytes = {
let mut body = req.body_mut();
let mut buf = BytesMut::with_capacity(body.size_hint().lower() as usize);
while let Some(chunk) = body.data().await {
buf.extend_from_slice(&chunk?);
}
buf.freeze()
};