resty icon indicating copy to clipboard operation
resty copied to clipboard

Return error when "RetryCount" is negative

Open kaduartur opened this issue 3 years ago • 1 comments

In my work, we have some requests that are created at runtime. We noticed that resty retries always start at zero and when retrying with a setting of 1 resty would retry this twice.

So we made an adjustment to (Retry -1), but we started having null pointer problems when using the response.Size() function because when our retry setting is zero, we pass -1 to the SetRetryCount function, and to executing the request we get no error and our response is null.

I am willing to make this change!

kaduartur avatar Aug 05 '21 17:08 kaduartur

@kaduartur Thanks for reaching out. I would like to clarify the fix approach (starting from 1 instead of 0??). I would like to avoid negative value input. Currently no validation, thinking to add that in v3.0.0.

While making changes, please this reference into consideration.

  • Code reference https://github.com/go-resty/resty/blob/c1fa35881e814e06d0b49c1ea899fe65738282e0/request.go#L743-L748
  • and this open PR #444

jeevatkm avatar Sep 12 '21 19:09 jeevatkm