fix: close and drain the response body always (#8847)

This commit is contained in:
Harshavardhana
2020-01-21 02:46:58 -08:00
committed by GitHub
parent 3011692d93
commit e2b3c083aa
9 changed files with 17 additions and 4 deletions
+4 -1
View File
@@ -304,9 +304,12 @@ func IsBackendOnline(ctx context.Context, clnt *http.Client, urlStr string) bool
if err != nil {
return false
}
if _, err = clnt.Do(req); err != nil {
resp, err := clnt.Do(req)
if err != nil {
clnt.CloseIdleConnections()
return !xnet.IsNetworkOrHostDown(err)
}
xhttp.DrainBody(resp.Body)
return true
}