-
Notifications
You must be signed in to change notification settings - Fork 18.7k
Description
The caller of http.Get and friends has a documented responsibility to call resp.Body.Close() on the response. Failure to do so prevents the http package from reusing the transport. @prattmic recently found this to be the cause of a problem in a production service (Googlers: cl/815710818).
We should experiment with augmenting the existing httpresponse analyzer (which currently detects only overeager calls to resp.Body.Close before we've inspected the error returned by http.Get) so that it also reports failure to close the response body.
(Interestingly, @bradfitz also recently found a related issue in which failure to drain the response body, even in the HTTP error case, caused the http package to fail to recycle resources in a timely manner, even when the calling code had correctly remembered to defer a call to resp.Body.Close().)