Remove TorHttpClientExtensions and move the code to ITorHttpClient.
DELETE
WalletWasabi/Tor/Http/Extensions/TorHttpClientExtensions.cs
-using System;
-using System.Net;
-using System.Net.Http;
-using System.Threading;
-using System.Threading.Tasks;
-using WalletWasabi.Tor.Http.Interfaces;
-
-namespace WalletWasabi.Tor.Http.Extensions
-{
- public static class TorHttpClientExtensions
- {
- /// <remarks>
- /// Throws OperationCancelledException if <paramref name="cancel"/> is set.
- /// </remarks>
- public static async Task<HttpResponseMessage> SendAndRetryAsync(this ITorHttpClient client, HttpMethod method, HttpStatusCode expectedCode, string relativeUri, int retry = 2, HttpContent content = null, CancellationToken cancel = default)
- {
- HttpResponseMessage response = null;
- while (retry-- > 0)
- {
- response?.Dispose();
- cancel.ThrowIfCancellationRequested();
- response = await client.SendAsync(method, relativeUri, content, cancel: cancel);
- if (response.StatusCode == expectedCode)
- {
- break;
- }
- try
- {
- await Task.Delay(1000, cancel);
- }
- catch (TaskCanceledException ex)
- {
- throw new OperationCanceledException(ex.Message, ex, cancel);
- }
- }
- return response;
- }
- }
-}

MODIFY
WalletWasabi/Tor/Http/Interfaces/ITorHttpClient.cs
WalletWasabi/Tor/Http/Interfaces/ITorHttpClient.cs
@@ -17,5 +17,35 @@ namespace WalletWasabi.Tor.Http.Interfaces
Task<HttpResponseMessage> SendAsync(HttpMethod method, string relativeUri, HttpContent? content = null, CancellationToken cancel = default);
Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancel = default);
+
+ /// <remarks>
+ /// Throws <see cref="OperationCanceledException"/> if <paramref name="cancel"/> is set.
+ /// </remarks>
+ public async Task<HttpResponseMessage?> SendAndRetryAsync(HttpMethod method, HttpStatusCode expectedCode, string relativeUri, int retry = 2, HttpContent? content = null, CancellationToken cancel = default)
+ {
+ HttpResponseMessage? response = null;
+
+ while (retry-- > 0)
+ {
+ response?.Dispose();
+ cancel.ThrowIfCancellationRequested();
+ response = await SendAsync(method, relativeUri, content, cancel: cancel).ConfigureAwait(false);
+
+ if (response.StatusCode == expectedCode)
+ {
+ break;
+ }
+
+ try
+ {
+ await Task.Delay(1000, cancel).ConfigureAwait(false);
+ }
+ catch (TaskCanceledException ex)
+ {
+ throw new OperationCanceledException(ex.Message, ex, cancel);
+ }
+ }
+ return response;
+ }
}
}

Remove TorHttpClientExtensions and move the code to ITorHttpClient.