diff options
author | Emma [it/its]@Rory& <root@rory.gay> | 2024-01-05 12:22:42 +0100 |
---|---|---|
committer | Emma [it/its]@Rory& <root@rory.gay> | 2024-01-05 12:22:42 +0100 |
commit | f215dca816745ef54f5436d6cea9350d6dcd3982 (patch) | |
tree | 2749bcd4d1297943478b6080d5688ef642ca1d40 /LibMatrix/Extensions | |
parent | ToObject and ToJson for MatrixException (diff) | |
download | LibMatrix-f215dca816745ef54f5436d6cea9350d6dcd3982.tar.xz |
Cleanup
Diffstat (limited to 'LibMatrix/Extensions')
-rw-r--r-- | LibMatrix/Extensions/HttpClientExtensions.cs | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/LibMatrix/Extensions/HttpClientExtensions.cs b/LibMatrix/Extensions/HttpClientExtensions.cs index 17cc31d..71bb0e5 100644 --- a/LibMatrix/Extensions/HttpClientExtensions.cs +++ b/LibMatrix/Extensions/HttpClientExtensions.cs @@ -37,7 +37,7 @@ public class MatrixHttpClient : HttpClient { return options; } - public override async Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken) { + public async Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken) { if (request.RequestUri is null) throw new NullReferenceException("RequestUri is null"); if (!request.RequestUri.IsAbsoluteUri) request.RequestUri = new Uri(BaseAddress, request.RequestUri); // if (AssertedUserId is not null) request.RequestUri = request.RequestUri.AddQuery("user_id", AssertedUserId); @@ -58,15 +58,18 @@ public class MatrixHttpClient : HttpClient { } HttpResponseMessage responseMessage; - try { + // try { responseMessage = await base.SendAsync(request, cancellationToken); - } - catch (Exception e) { - typeof(HttpRequestMessage).GetField("_sendStatus", BindingFlags.NonPublic | BindingFlags.Instance) - ?.SetValue(request, 0); - await Task.Delay(2500, cancellationToken); - return await SendAsync(request, cancellationToken); - } + // } + // catch (Exception e) { + // if (requestSettings is { Retries: 0 }) throw; + // typeof(HttpRequestMessage).GetField("_sendStatus", BindingFlags.NonPublic | BindingFlags.Instance) + // ?.SetValue(request, 0); + // await Task.Delay(requestSettings?.RetryDelay ?? 2500, cancellationToken); + // if(requestSettings is not null) requestSettings.Retries--; + // return await SendAsync(request, cancellationToken); + // throw; + // } if (responseMessage.IsSuccessStatusCode) return responseMessage; |