HTTP request and response duplication for multiple use

I did notice that you’re manually cloning your request and response, and it looks like all for the sake of preserving the body. But the documentation for DumpRequest (and by extension DumpResponse) state that those methods preserve the body for you:

If body is true, DumpRequest also returns the body. To do so, it consumes req.Body and then replaces it with a new io.ReadCloser that yields the same bytes.

So, do you still need to manually clone the objects? If not, might that reduce some memory usage?

Looking back at the previous post you made about this subject, peakedshout’s suggestion looks to be complete and efficient from a bytes-copying perspective. How did that solution work for you?