Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -523,6 +523,11 @@ func baseRetryPolicy(resp *http.Response, err error) (bool, error) {
return true, nil
}

// Retry when the response is nil as this can indicate a closed connection or some other temporary condition
if resp == nil {
return true, nil
}

// 429 Too Many Requests is recoverable. Sometimes the server puts
// a Retry-After response header to indicate when the server is
// available to start processing request from client.
Expand Down
13 changes: 13 additions & 0 deletions client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1268,3 +1268,16 @@ func TestClient_RedirectWithBody(t *testing.T) {
t.Fatalf("Expected the client to be redirected 2 times, got: %d", atomic.LoadInt32(&redirects))
}
}

func TestClient_baseRetryPolicy(t *testing.T) {
t.Parallel()
var response *http.Response = nil

ok, err := baseRetryPolicy(response, nil)
if !ok {
t.Fatalf("expected %v, got %v", true, ok)
}
if err != nil {
t.Fatalf("no error expected")
}
}