/// <summary> /// Send a HTTP request /// </summary> /// <param name="httpRequest">The HTTP request<see cref="HttpRequestMessage"/>needs to be sent.</param> /// <param name="cancellationToken">The <see cref="CancellationToken"/> for the request.</param> /// <returns></returns> protected async override Task <HttpResponseMessage> SendAsync(HttpRequestMessage httpRequest, CancellationToken cancellationToken) { RetryOption = httpRequest.GetMiddlewareOption <RetryHandlerOption>() ?? RetryOption; var response = await base.SendAsync(httpRequest, cancellationToken); // Check whether retries are permitted and that the MaxRetry value is a non - negative, non - zero value if (ShouldRetry(response) && httpRequest.IsBuffered() && RetryOption.MaxRetry > 0 && RetryOption.ShouldRetry(RetryOption.Delay, 0, response)) { response = await SendRetryAsync(response, cancellationToken); } return(response); }
/// <summary> /// Construct a new <see cref="RetryHandler"/> /// </summary> /// <param name="innerHandler">An HTTP message handler to pass to the <see cref="HttpMessageHandler"/> for sending requests.</param> /// <param name="retryOption">An OPTIONAL <see cref="Microsoft.Graph.RetryHandlerOption"/> to configure <see cref="RetryHandler"/></param> public RetryHandler(HttpMessageHandler innerHandler, RetryHandlerOption retryOption = null) : this(retryOption) { InnerHandler = innerHandler; }
/// <summary> /// Construct a new <see cref="RetryHandler"/> /// </summary> /// <param name="retryOption">An OPTIONAL <see cref="Microsoft.Graph.RetryHandlerOption"/> to configure <see cref="RetryHandler"/></param> public RetryHandler(RetryHandlerOption retryOption = null) { RetryOption = retryOption ?? new RetryHandlerOption(); }