From d70ea40a159de6dc565fc60e742b6032a34c4bdc Mon Sep 17 00:00:00 2001 From: danischm Date: Tue, 9 Jan 2024 17:05:54 +0100 Subject: [PATCH] Retry on 429 responses --- CHANGELOG.md | 4 ++++ client.go | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e5c3a7d..b50aa4d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.1.2 (unreleased) + +- Retry on 429 HTTP responses + ## 0.1.1 - Add option to set default maximum waiting time for async operations and override ip per request diff --git a/client.go b/client.go index 768e699..f73b9d3 100644 --- a/client.go +++ b/client.go @@ -222,7 +222,7 @@ func (client *Client) Do(req Req) (Res, error) { log.Printf("[ERROR] HTTP Request failed: StatusCode %v", httpRes.StatusCode) log.Printf("[DEBUG] Exit from Do method") return res, fmt.Errorf("HTTP Request failed: StatusCode %v", httpRes.StatusCode) - } else if httpRes.StatusCode == 408 || (httpRes.StatusCode >= 502 && httpRes.StatusCode <= 504) { + } else if httpRes.StatusCode == 408 || httpRes.StatusCode == 429 || (httpRes.StatusCode >= 502 && httpRes.StatusCode <= 504) { log.Printf("[ERROR] HTTP Request failed: StatusCode %v, Retries: %v", httpRes.StatusCode, attempts) continue } else {