safe Useragent as string and export settings after changing
This commit is contained in:
parent
2dd82aad13
commit
3ca6245fc2
@ -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)
|
||||
|
@ -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()
|
||||
|
Loading…
Reference in New Issue
Block a user