httploader: Close resp body on bad status code

Related to #5158
This commit is contained in:
Matthew Holt 2022-10-24 12:18:32 -06:00
parent bbe3663167
commit 817470dd66
No known key found for this signature in database
GPG Key ID: 2A349DD577D586A5

View File

@ -124,6 +124,7 @@ func attemptHttpCall(client *http.Client, request *http.Request) (*http.Response
if err != nil {
return nil, fmt.Errorf("problem calling http loader url: %v", err)
} else if resp.StatusCode < 200 || resp.StatusCode > 499 {
resp.Body.Close()
return nil, fmt.Errorf("bad response status code from http loader url: %v", resp.StatusCode)
}
return resp, nil