Skip to content

Commit

Permalink
fix: add more missing pointer checks
Browse files Browse the repository at this point in the history
Signed-off-by: rare-magma <[email protected]>
  • Loading branch information
rare-magma committed Jan 19, 2025
1 parent 2bd588c commit 6919396
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 @@ -80,14 +80,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 6919396

Please sign in to comment.