2
0

safe Useragent as string and export settings after changing

This commit is contained in:
Glax 2024-01-31 19:00:38 +01:00
parent 2dd82aad13
commit 3ca6245fc2
2 changed files with 6 additions and 3 deletions

View File

@ -14,7 +14,7 @@ internal class HttpDownloadClient : DownloadClient
public HttpDownloadClient(GlobalBase clone, Dictionary<byte, int> rateLimitRequestsPerMinute) : base(clone, rateLimitRequestsPerMinute)
{
Client.DefaultRequestHeaders.UserAgent.Add(settings.userAgent);
Client.DefaultRequestHeaders.TryAddWithoutValidation("User-Agent", settings.userAgent);
}
protected override RequestResult MakeRequestInternal(string url, string? referrer = null, string? clickButton = null)

View File

@ -13,7 +13,9 @@ public class TrangaSettings
public string workingDirectory { get; private set; }
public int apiPortNumber { get; init; }
public string styleSheet { get; private set; }
public ProductInfoHeaderValue userAgent { get; set; } = new ("Tranga", "1.0");
public string userAgent { get; set; } =
$"Tranga ({Enum.GetName(Environment.OSVersion.Platform)}; {(Environment.Is64BitOperatingSystem ? "x64" : "")}) / 1.0";
[JsonIgnore] public string settingsFilePath => Path.Join(workingDirectory, "settings.json");
[JsonIgnore] public string libraryConnectorsFilePath => Path.Join(workingDirectory, "libraryConnectors.json");
[JsonIgnore] public string notificationConnectorsFilePath => Path.Join(workingDirectory, "notificationConnectors.json");
@ -123,7 +125,8 @@ public class TrangaSettings
public void UpdateUserAgent(string customUserAgent)
{
this.userAgent = new ProductInfoHeaderValue(ProductHeaderValue.Parse(customUserAgent));
this.userAgent = customUserAgent;
ExportSettings();
}
public void ExportSettings()