lib/ur: Correct freaky error handling (fixes #6499) (#6500)

This commit is contained in:
Jakob Borg 2020-04-06 09:53:37 +02:00 committed by GitHub
parent b7ba401c0b
commit 88cabb9e0a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -385,16 +385,18 @@ func (s *Service) sendUsageReport(ctx context.Context) error {
}, },
} }
req, err := http.NewRequest("POST", s.cfg.Options().URURL, &b) req, err := http.NewRequest("POST", s.cfg.Options().URURL, &b)
if err == nil { if err != nil {
return err
}
req.Header.Set("Content-Type", "application/json") req.Header.Set("Content-Type", "application/json")
req.Cancel = ctx.Done() req.Cancel = ctx.Done()
var resp *http.Response resp, err := client.Do(req)
resp, err = client.Do(req) if err != nil {
resp.Body.Close()
}
return err return err
} }
resp.Body.Close()
return nil
}
func (s *Service) serve(ctx context.Context) { func (s *Service) serve(ctx context.Context) {
s.cfg.Subscribe(s) s.cfg.Subscribe(s)