private bool ShouldRetry()

in sdk/Common/Communication/RetryableServiceClient.cs [138:159]


        private bool ShouldRetry(ServiceRequest request, Exception ex, int retryTimes)
        {
            if (retryTimes > MaxRetryTimes || !request.IsRepeatable)
                return false;

            var webException = ex as WebException;
            if (webException != null)
            {
                var httpWebResponse = webException.Response as HttpWebResponse;
                if (httpWebResponse != null &&
                    (httpWebResponse.StatusCode == HttpStatusCode.ServiceUnavailable ||
                     httpWebResponse.StatusCode == HttpStatusCode.InternalServerError))
                {
                    return true;
                }
            }

            if (ShouldRetryCallback != null && ShouldRetryCallback(ex))
                return true;

            return false;
        }