mirror of
https://github.com/Tyrrrz/DiscordChatExporter.git
synced 2025-05-27 13:14:17 -04:00
Remove unnecessary code
This commit is contained in:
parent
b71af710c7
commit
3487849eba
2 changed files with 2 additions and 15 deletions
|
@ -1,8 +1,4 @@
|
|||
using System.Globalization;
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
using System.Net.Http.Headers;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Net.Http.Headers;
|
||||
|
||||
namespace DiscordChatExporter.Core.Utils.Extensions;
|
||||
|
||||
|
@ -12,13 +8,4 @@ public static class HttpExtensions
|
|||
headers.TryGetValues(name, out var values)
|
||||
? string.Concat(values)
|
||||
: null;
|
||||
|
||||
public static HttpStatusCode? TryGetStatusCode(this HttpRequestException ex) =>
|
||||
// This is extremely frail, but there's no other way
|
||||
Regex
|
||||
.Match(ex.Message, @": (\d+) \(")
|
||||
.Groups[1]
|
||||
.Value
|
||||
.NullIfWhiteSpace()?
|
||||
.Pipe(s => (HttpStatusCode) int.Parse(s, CultureInfo.InvariantCulture));
|
||||
}
|
|
@ -23,7 +23,7 @@ public static class Http
|
|||
private static bool IsRetryableException(Exception exception) =>
|
||||
exception.GetSelfAndChildren().Any(ex =>
|
||||
ex is TimeoutException or SocketException or AuthenticationException ||
|
||||
ex is HttpRequestException hrex && IsRetryableStatusCode(hrex.TryGetStatusCode() ?? HttpStatusCode.OK)
|
||||
ex is HttpRequestException hrex && IsRetryableStatusCode(hrex.StatusCode ?? HttpStatusCode.OK)
|
||||
);
|
||||
|
||||
public static IAsyncPolicy ResiliencePolicy { get; } =
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue