mirror of
https://github.com/Tyrrrz/DiscordChatExporter.git
synced 2026-03-31 17:43:04 -06:00
Cache headers
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
parent
06117adf47
commit
eccc481b44
|
|
@ -74,6 +74,11 @@ public class DiscordClient(
|
||||||
if (tokenKind != TokenKind.Bot)
|
if (tokenKind != TokenKind.Bot)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
{
|
||||||
|
// Cache headers from the external API so we don't make this request on every call.
|
||||||
|
static Dictionary<string, string>? cachedHeaders;
|
||||||
|
|
||||||
|
if (cachedHeaders is null)
|
||||||
{
|
{
|
||||||
using var apiReq = new HttpRequestMessage(
|
using var apiReq = new HttpRequestMessage(
|
||||||
HttpMethod.Post,
|
HttpMethod.Post,
|
||||||
|
|
@ -93,8 +98,8 @@ public class DiscordClient(
|
||||||
|
|
||||||
var properties = root.GetProperty("properties");
|
var properties = root.GetProperty("properties");
|
||||||
|
|
||||||
string userAgent = proprties.GetProperty("user_agent").GetString()!;
|
string userAgent = properties.GetProperty("user_agent").GetString()!;
|
||||||
string browserVersion = proprties.GetProperty("browser_version").GetString()!;
|
string browserVersion = properties.GetProperty("browser_version").GetString()!;
|
||||||
string osType = properties.GetProperty("os").GetString()!;
|
string osType = properties.GetProperty("os").GetString()!;
|
||||||
|
|
||||||
string chromeMajor = browserVersion.Split('.')[0];
|
string chromeMajor = browserVersion.Split('.')[0];
|
||||||
|
|
@ -119,7 +124,10 @@ public class DiscordClient(
|
||||||
["x-super-properties"] = xspBase64,
|
["x-super-properties"] = xspBase64,
|
||||||
};
|
};
|
||||||
|
|
||||||
foreach (var kv in headers)
|
cachedHeaders = headers;
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (var kv in cachedHeaders)
|
||||||
request.Headers.TryAddWithoutValidation(kv.Key, kv.Value);
|
request.Headers.TryAddWithoutValidation(kv.Key, kv.Value);
|
||||||
}
|
}
|
||||||
catch { }
|
catch { }
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue