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 <rare-magma@posteo.eu>
  • Loading branch information
rare-magma committed Jan 19, 2025
1 parent 6dcdb8b commit 6c7eec4
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 @@ -51,6 +51,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 @@ -77,7 +80,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 6c7eec4

Please sign in to comment.