Skip to content

Close the response body in client.sendRequest

As per docu https://pkg.go.dev/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.

something like

if resp.Body != nil {
    defer resp.Body.Close()
}

should do there