Return error loading config on non-200 response

This commit is contained in:
Daniel Nelson 2019-02-05 15:15:58 -08:00
parent 7dffb1b5f9
commit 1a81e49d05
No known key found for this signature in database
GPG Key ID: CAAD59C9444F6155
1 changed files with 5 additions and 0 deletions

View File

@ -772,6 +772,11 @@ func fetchConfig(u *url.URL) ([]byte, error) {
if err != nil { if err != nil {
return nil, err return nil, err
} }
if resp.StatusCode != http.StatusOK {
return nil, fmt.Errorf("failed to retrieve remote config: %s", resp.Status)
}
defer resp.Body.Close() defer resp.Body.Close()
return ioutil.ReadAll(resp.Body) return ioutil.ReadAll(resp.Body)
} }