Skip to content

Commit

Permalink
fix: add more pointer check
Browse files Browse the repository at this point in the history
Signed-off-by: rare-magma <rare-magma@posteo.eu>
  • Loading branch information
rare-magma committed Jan 19, 2025
1 parent 6c7eec4 commit 3af27cc
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,14 +73,14 @@ func (t *retryableTransport) RoundTrip(req *http.Request) (*http.Response, error
for shouldRetry(err, resp) && retries < retryCount {
backoff := time.Duration(math.Pow(2, float64(retries))) * time.Second
time.Sleep(backoff)
if resp.Body != nil {
if resp != nil && resp.Body != nil {
io.Copy(io.Discard, resp.Body)
resp.Body.Close()
}
if req.Body != nil {
req.Body = io.NopCloser(bytes.NewBuffer(bodyBytes))
}
if resp != nil {
if resp != nil && resp.Status != "" {
log.Printf("Previous request failed with %s", resp.Status)
}
log.Printf("Retry %d of request to: %s", retries+1, req.URL)
Expand Down

0 comments on commit 3af27cc

Please sign in to comment.