diff --git a/http.go b/http.go index 029e584..d8a109a 100644 --- a/http.go +++ b/http.go @@ -246,7 +246,6 @@ func (c *Client) retryDo(ctx context.Context, req *http.Request) (*http.Response if req != nil && req.Body != nil { originalBody, err = copyBody(req.Body) - resetBody(req, originalBody) } if err != nil { @@ -257,6 +256,10 @@ func (c *Client) retryDo(ctx context.Context, req *http.Request) (*http.Response // try request and if fail run 10 retries err = retry.Do(func() error { + if req != nil && req.Body != nil { + resetBody(req, originalBody) + } + resp, err = c.http.Do(req) if err == nil { @@ -265,10 +268,6 @@ func (c *Client) retryDo(ctx context.Context, req *http.Request) (*http.Response return errors.Wrap(err, "qbit re-login failed") } - if req.Body != nil { - resetBody(req, originalBody) - } - retry.Delay(100 * time.Millisecond) return errors.New("qbit re-login")