| 1040 | } |
| 1041 | |
| 1042 | bool SC::HttpClientSession::shouldRetry(HttpClientSessionRetryState& state, Result transportResult, |
| 1043 | const HttpClientResponse* response) const |
| 1044 | { |
| 1045 | if (not initialized or state.attemptsStarted == 0 or state.attemptsStarted >= state.policy.maxAttempts) |
| 1046 | { |
| 1047 | return false; |
| 1048 | } |
| 1049 | |
| 1050 | const bool methodCanRetry = sessionIsIdempotentMethod(state.method) or |
| 1051 | (state.policy.retryNonIdempotentReplayableBody and state.requestBodyReplayable); |
| 1052 | if (not methodCanRetry) |
| 1053 | { |
| 1054 | return false; |
| 1055 | } |
| 1056 | |
| 1057 | const bool transportShouldRetry = not transportResult and state.policy.retryTransportErrors; |
| 1058 | const bool responseShouldRetry = response != nullptr and state.policy.retryHttpStatusCodes and |
| 1059 | sessionIsRetryableStatusCode(response->statusCode); |
| 1060 | if (not transportShouldRetry and not responseShouldRetry) |
| 1061 | { |
| 1062 | return false; |
| 1063 | } |
| 1064 | |
| 1065 | state.attemptsStarted += 1; |
| 1066 | return true; |
| 1067 | } |
| 1068 | |
| 1069 | bool SC::HttpClientSession::isIdempotentMethod(HttpClientRequest::Method method) |
| 1070 | { |