Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 21 additions & 1 deletion src/Identity/test/Identity.Test/CdnScriptTaghelperTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using System.Net.Http;
using System.Security.Cryptography;
using System.Text.RegularExpressions;
using System.Threading;
using System.Threading.Tasks;
using Xunit;
using Xunit.Abstractions;
Expand Down Expand Up @@ -38,7 +39,7 @@ public async Task IdentityUI_ScriptTags_SubresourceIntegrityCheck()
Assert.NotEmpty(scriptTags);

var shasum = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
using (var client = new HttpClient())
using (var client = new HttpClient(new RetryHandler(new HttpClientHandler() { })))
{
foreach (var script in scriptTags)
{
Expand All @@ -62,6 +63,25 @@ public async Task IdentityUI_ScriptTags_SubresourceIntegrityCheck()
});
}

class RetryHandler : DelegatingHandler
{
public RetryHandler(HttpMessageHandler innerHandler) : base(innerHandler) { }
protected override async Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
{
HttpResponseMessage result = null;
for (var i = 0; i < 10; i++)
{
result = await base.SendAsync(request, cancellationToken);
if (result.IsSuccessStatusCode)
{
return result;
}
await Task.Delay(1000);
}
return result;
}
}

private struct ScriptTag
{
public string Src;
Expand Down