/// <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); }
// For testing only internal PayjoinClient(ITorHttpClient httpClient) { TorHttpClient = Guard.NotNull(nameof(httpClient), httpClient); }
public WasabiClient(ITorHttpClient torHttpClient) : base(torHttpClient) { }
// For testing only internal PayjoinClient(ITorHttpClient httpClient) { PaymentUrl = httpClient.DestinationUri; TorHttpClient = Guard.NotNull(nameof(httpClient), httpClient); }
protected TorDisposableBase(ITorHttpClient torClient) { TorClient = torClient; }
/// <param name="torSocks5EndPoint">if null, then localhost:9050</param> protected TorDisposableBase(Func <Uri> baseUriAction, EndPoint torSocks5EndPoint) { TorClient = new TorHttpClient(baseUriAction, torSocks5EndPoint, isolateStream: true); }
/// <param name="torSocks5EndPoint">if null, then localhost:9050</param> protected TorDisposableBase(Uri baseUri, EndPoint torSocks5EndPoint) { TorClient = new TorHttpClient(baseUri, torSocks5EndPoint, isolateStream: true); }
public WasabiClient(ITorHttpClient torHttpClient) { TorClient = torHttpClient; }
// For testing only internal PayjoinClient(Uri paymentUrl, ITorHttpClient httpClient) { PaymentUrl = paymentUrl; TorHttpClient = Guard.NotNull(nameof(httpClient), httpClient); }