MCPcopy Create free account
hub / github.com/Pagghiu/SaneCppLibraries / shouldRetry

Method shouldRetry

Libraries/HttpClient/HttpClientSession.cpp:1042–1067  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1040}
1041
1042bool 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
1069bool SC::HttpClientSession::isIdempotentMethod(HttpClientRequest::Method method)
1070{

Callers 1

sessionLayerMethod · 0.80

Calls 2

Tested by 1

sessionLayerMethod · 0.64