/// <summary> /// Used <code>retryCount</code> and <code>requestSentRetryEnabled</code> to determine /// if the given method should be retried. /// </summary> /// <remarks> /// Used <code>retryCount</code> and <code>requestSentRetryEnabled</code> to determine /// if the given method should be retried. /// </remarks> public virtual bool RetryRequest(IOException exception, int executionCount, HttpContext context) { Args.NotNull(exception, "Exception parameter"); Args.NotNull(context, "HTTP context"); if (executionCount > this.retryCount) { // Do not retry if over max retry count return(false); } if (this.nonRetriableClasses.Contains(exception.GetType())) { return(false); } else { foreach (Type rejectException in this.nonRetriableClasses) { if (rejectException.IsInstanceOfType(exception)) { return(false); } } } HttpClientContext clientContext = ((HttpClientContext)HttpClientContext.Adapt(context )); IHttpRequest request = clientContext.GetRequest(); if (RequestIsAborted(request)) { return(false); } if (HandleAsIdempotent(request)) { // Retry if the request is considered idempotent return(true); } if (!clientContext.IsRequestSent() || this.requestSentRetryEnabled) { // Retry if the request has not been sent fully or // if it's OK to retry methods that have been sent return(true); } // otherwise do not retry return(false); }