Move `User-Agent` value to `VersionInfo` and ensure it's valid

fixes e22082c6b
This commit is contained in:
YoshiRulz 2024-09-02 05:21:56 +10:00
parent 133ff5a77e
commit cda23dd38e
No known key found for this signature in database
GPG Key ID: C4DE31C245353FB7
2 changed files with 4 additions and 1 deletions

View File

@ -25,7 +25,7 @@ namespace BizHawk.Client.Common
_takeScreenshotCallback = takeScreenshotCallback; _takeScreenshotCallback = takeScreenshotCallback;
GetUrl = getURL; GetUrl = getURL;
PostUrl = postURL; PostUrl = postURL;
_client.DefaultRequestHeaders.UserAgent.ParseAdd($"BizHawk/{VersionInfo.GetEmuVersion()}"); _client.DefaultRequestHeaders.UserAgent.ParseAdd(VersionInfo.UserAgentEscaped);
} }
public string ExecGet(string url = null) => Get(url ?? GetUrl).Result; public string ExecGet(string url = null) => Get(url ?? GetUrl).Result;

View File

@ -22,6 +22,8 @@ namespace BizHawk.Common
public static readonly string BizHawkContributorsListURI = "https://github.com/TASEmulators/BizHawk/graphs/contributors"; public static readonly string BizHawkContributorsListURI = "https://github.com/TASEmulators/BizHawk/graphs/contributors";
public static readonly string UserAgentEscaped;
static VersionInfo() static VersionInfo()
{ {
var path = Path.Combine( var path = Path.Combine(
@ -37,6 +39,7 @@ namespace BizHawk.Common
CustomBuildString = lines[0]; CustomBuildString = lines[0];
} }
} }
UserAgentEscaped = $"BizHawk/{MainVersion}{(DeveloperBuild ? "-dev" : string.Empty)}";
} }
public static (string Label, string TargetURI) GetGitCommitLink() public static (string Label, string TargetURI) GetGitCommitLink()