示例#1
0
        /// <inheritdoc/>
        public async Task <string> DownloadFrom(Uri url)
        {
            uint attempt = 1;

            while (true)
            {
                try
                {
                    var request = httpClient.GetStringAsync(url);
                    return(await request);
                }
                catch (HttpRequestException ex) when(ex.Message.Contains(/*HTTP Fehler*/ " 403 "))
                {
                    if (attempt <= _maxRetries)
                    {
                        System.Threading.Thread.Sleep(
                            RetryStrategy.CalculateExponentialBackoff(timeSlotForRetry, attempt)
                            );
                        ++attempt;
                        continue;
                    }

                    throw new Exception($"Das Abrufen von Hypertext aus der URL {url} is gescheitert!", ex);
                }
            }
        }