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
1 changed files with 10 additions and 8 deletions

View File

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