Skip to content
代码片段 群组 项目
未验证 提交 efe9b95b 编辑于 作者: Hao Kung's avatar Hao Kung 提交者: GitHub
浏览文件

Improve cdn test reliability (#6044)

上级 686ce02c
No related branches found
No related tags found
无相关合并请求
......@@ -7,6 +7,7 @@ using System.IO;
using System.Net.Http;
using System.Security.Cryptography;
using System.Text.RegularExpressions;
using System.Threading;
using System.Threading.Tasks;
using Xunit;
using Xunit.Abstractions;
......@@ -38,7 +39,7 @@ namespace Microsoft.AspNetCore.Identity.Test
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)
{
......@@ -62,6 +63,25 @@ namespace Microsoft.AspNetCore.Identity.Test
});
}
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;
......
0% 加载中 .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册