Skip to content

Commit 8988107

Browse files
authored
diagnose: always use IHttpClientFactory for diagnose (#942)
The Network diagnostic currently makes two passes of the tests, one using a 'raw' `HttpClient` and another using one created by the product `HttpClientFactory`. However, we've not actually been using the factory-built client in the tests! Furthermore, the raw HTTP client will not exercise test correctly if the machine is behind a corporate proxy, so let's just drop that option. Fixes #927
2 parents fef64ec + da646ea commit 8988107

File tree

1 file changed

+2
-14
lines changed

1 file changed

+2
-14
lines changed

src/shared/Core/Diagnostics/NetworkingDiagnostic.cs

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -25,23 +25,11 @@ public NetworkingDiagnostic(IHttpClientFactory httpFactory)
2525

2626
protected override async Task<bool> RunInternalAsync(StringBuilder log, IList<string> additionalFiles)
2727
{
28-
log.AppendLine("Checking basic networking and HTTP stack...");
28+
log.AppendLine("Checking networking and HTTP stack...");
2929
log.Append("Creating HTTP client...");
30-
using var rawHttpClient = new HttpClient();
30+
using var httpClient = _httpFactory.CreateClient();
3131
log.AppendLine(" OK");
3232

33-
if (!await RunTestAsync(log, rawHttpClient)) return false;
34-
35-
log.AppendLine("Testing with IHttpClientFactory created HTTP client...");
36-
log.Append("Creating HTTP client...");
37-
using var contextHttpClient = _httpFactory.CreateClient();
38-
log.AppendLine(" OK");
39-
40-
return await RunTestAsync(log, rawHttpClient);
41-
}
42-
43-
private static async Task<bool> RunTestAsync(StringBuilder log, HttpClient httpClient)
44-
{
4533
bool hasNetwork = NetworkInterface.GetIsNetworkAvailable();
4634
log.AppendLine($"IsNetworkAvailable: {hasNetwork}");
4735

0 commit comments

Comments
 (0)