use task.run to add headers instead

This commit is contained in:
Wave Dev 2026-03-15 20:15:58 +00:00 committed by GitHub
parent 5b6508d780
commit 825b1470e1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -50,7 +50,7 @@ public class DiscordClient(
// discord flags requests that don't look like a real browser // discord flags requests that don't look like a real browser
if (tokenKind != TokenKind.Bot) if (tokenKind != TokenKind.Bot)
{ {
try await Task.Run(async () =>
{ {
// Cache headers from the external API so we don't make this request on every call. // Cache headers from the external API so we don't make this request on every call.
@ -105,8 +105,7 @@ public class DiscordClient(
foreach (var kv in _cachedBrowserHeaders) foreach (var kv in _cachedBrowserHeaders)
if (!request.Headers.Contains(kv.Key)) request.Headers.TryAddWithoutValidation(kv.Key, kv.Value); if (!request.Headers.Contains(kv.Key)) request.Headers.TryAddWithoutValidation(kv.Key, kv.Value);
} })
catch { }
} }
var response = await Http.Client.SendAsync( var response = await Http.Client.SendAsync(