Using DumpResponse can Lead to Unclosed Response Bodies
On the surface httputil.DumpResponse(resp *http.Response, body bool) ([]byte, error) seems like a very simple function that serializes a http.Response into a []byte. However, using this function correctly is harder than it seems. In fact, even the standard library’s example has a subtle bug that stems from using httputil.DumpResponse(). Let’s take a look at the example in question: