mirror of
https://github.com/prometheus/prometheus.git
synced 2026-06-07 15:42:12 -04:00
Merge pull request #1070 from amorken/forgotten-close
Close HTTP connections on HTTP errors too.
This commit is contained in:
commit
d6ed1df4fb
1 changed files with 2 additions and 1 deletions
|
|
@ -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 a new issue