You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The following code is fine, because it closes the body only when the error is nil, but gets response body must be closed errors on both the d.client.Do(req) lines.
func (d*Dispatcher) call(req*http.Request) {
// keep retrying the request until the error is niltries:=0wait:=time.Secondresp, err:=d.client.Do(req)
forerr!=nil&&tries<d.retries {
// wait a whiletime.Sleep(wait)
wait*=2// try againresp, err=d.client.Do(req)
tries++
}
// maximum retries exceedediferr!=nil {
// log error herereturn
}
// now the request was successful; do some work// close the body nowiferr=resp.Body.Close(); err!=nil {
// log error
}
}
The text was updated successfully, but these errors were encountered:
The following code is fine, because it closes the body only when the error is
nil
, but getsresponse body must be closed
errors on both thed.client.Do(req)
lines.The text was updated successfully, but these errors were encountered: