Skip to content

Commit

Permalink
Close file bodies of HTTP probes.
Browse files Browse the repository at this point in the history
  • Loading branch information
emmanuel committed Jan 9, 2019
1 parent 427d68b commit c97981f
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
3 changes: 2 additions & 1 deletion config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,10 +142,11 @@ func (s *HTTPProbe) UnmarshalYAML(unmarshal func(interface{}) error) error {
return errors.New("at most one of body & body_file may be configured")
}
if s.BodyFile != "" {
_, err := os.Open(s.BodyFile)
file, err := os.Open(s.BodyFile)
if err != nil {
return err
}
defer file.Close()
}
return nil
}
Expand Down
1 change: 1 addition & 0 deletions prober/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,7 @@ func ProbeHTTP(ctx context.Context, target string, module config.Module, registr
level.Error(logger).Log("msg", "Error opening body file", "err", err)
return
}
defer file.Close()
body = file
}

Expand Down

0 comments on commit c97981f

Please sign in to comment.