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,15 +385,17 @@ 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 {
req.Header.Set("Content-Type", "application/json") return err
req.Cancel = ctx.Done()
var resp *http.Response
resp, err = client.Do(req)
resp.Body.Close()
} }
req.Header.Set("Content-Type", "application/json")
return err req.Cancel = ctx.Done()
resp, err := client.Do(req)
if err != nil {
return err
}
resp.Body.Close()
return nil
} }
func (s *Service) serve(ctx context.Context) { func (s *Service) serve(ctx context.Context) {