-
Notifications
You must be signed in to change notification settings - Fork 583
Core: close response body, when body is not used #1949
Copy link
Copy link
Closed
Description
While working on #1942 I noticed that in certain cases there can be a resource leak. E.g. in delete operations:
| resp, err := c.Delete(deleteURL(c, id), nil) |
When JSONResponse parameter is nil, the response body is not closed, therefore the existing connection cannot be reused.
See https://golang.org/pkg/net/http/#Client.Do
If the returned error is nil, the Response will contain a non-nil Body which the user is expected to close. If the Body is not both read to EOF and closed, the Client's underlying RoundTripper (typically Transport) may not be able to re-use a persistent TCP connection to the server for a subsequent "keep-alive" request.
@jtopjian is it something that should be considered or do I dramatize things?
Relates to #1015
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels