Exemple #1
0
    /// <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);
    }
Exemple #2
0
 // For testing only
 internal PayjoinClient(ITorHttpClient httpClient)
 {
     TorHttpClient = Guard.NotNull(nameof(httpClient), httpClient);
 }
 public WasabiClient(ITorHttpClient torHttpClient) : base(torHttpClient)
 {
 }
Exemple #4
0
 // 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);
 }
Exemple #8
0
 public WasabiClient(ITorHttpClient torHttpClient)
 {
     TorClient = torHttpClient;
 }
Exemple #9
0
 // For testing only
 internal PayjoinClient(Uri paymentUrl, ITorHttpClient httpClient)
 {
     PaymentUrl    = paymentUrl;
     TorHttpClient = Guard.NotNull(nameof(httpClient), httpClient);
 }