Skip to content

Commit

Permalink
fix: add missing pointer check
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 c1d5f5c commit 6080268
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ func shouldRetry(err error, resp *http.Response) bool {
if err != nil {
return true
}
if resp == nil {
return true
}
switch resp.StatusCode {
case http.StatusInternalServerError, http.StatusBadGateway, http.StatusServiceUnavailable, http.StatusGatewayTimeout:
return true
Expand All @@ -63,7 +66,9 @@ func (t *retryableTransport) RoundTrip(req *http.Request) (*http.Response, error
if req.Body != nil {
req.Body = io.NopCloser(bytes.NewBuffer(bodyBytes))
}
log.Printf("Previous request failed with %s", resp.Status)
if resp != nil {
log.Printf("Previous request failed with %s", resp.Status)
}
log.Printf("Retry %d of request to: %s", retries+1, req.URL)
resp, err = t.transport.RoundTrip(req)
retries++
Expand Down

0 comments on commit 6080268

Please sign in to comment.