mirror of
https://github.com/prometheus/prometheus
synced 2025-01-30 11:44:07 +00:00
Merge pull request #1070 from amorken/forgotten-close
Close HTTP connections on HTTP errors too.
This commit is contained in:
commit
d6ed1df4fb
@ -437,6 +437,8 @@ func (t *Target) scrape(appender storage.SampleAppender) (err error) {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
|
||||
if resp.StatusCode != http.StatusOK {
|
||||
return fmt.Errorf("server returned HTTP status %s", resp.Status)
|
||||
}
|
||||
@ -445,7 +447,6 @@ func (t *Target) scrape(appender storage.SampleAppender) (err error) {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
|
||||
sdec := expfmt.SampleDecoder{
|
||||
Dec: dec,
|
||||
|
Loading…
Reference in New Issue
Block a user