Update HttpClient user agent format

TIL user agents have a specific syntax lol
This commit is contained in:
pizzaboxer 2024-09-30 10:08:41 +01:00
parent 43ab5626ee
commit 84da94c3f2
No known key found for this signature in database
GPG Key ID: 59D4A1DBAD0F2BA8
3 changed files with 15 additions and 5 deletions

View File

@ -141,10 +141,22 @@ namespace Bloxstrap
Logger.WriteLine(LOG_IDENT, $"Starting {ProjectName} v{Version}"); Logger.WriteLine(LOG_IDENT, $"Starting {ProjectName} v{Version}");
string userAgent = $"{ProjectName}/{Version}";
if (IsActionBuild) if (IsActionBuild)
{
Logger.WriteLine(LOG_IDENT, $"Compiled {BuildMetadata.Timestamp.ToFriendlyString()} from commit {BuildMetadata.CommitHash} ({BuildMetadata.CommitRef})"); Logger.WriteLine(LOG_IDENT, $"Compiled {BuildMetadata.Timestamp.ToFriendlyString()} from commit {BuildMetadata.CommitHash} ({BuildMetadata.CommitRef})");
if (IsProductionBuild)
userAgent += $" (Production)";
else
userAgent += $" (Artifact {BuildMetadata.CommitHash}, {BuildMetadata.CommitRef})";
}
else else
{
Logger.WriteLine(LOG_IDENT, $"Compiled {BuildMetadata.Timestamp.ToFriendlyString()} from {BuildMetadata.Machine}"); Logger.WriteLine(LOG_IDENT, $"Compiled {BuildMetadata.Timestamp.ToFriendlyString()} from {BuildMetadata.Machine}");
userAgent += $" (Build {BuildMetadata.Machine})";
}
Logger.WriteLine(LOG_IDENT, $"Loaded from {Paths.Process}"); Logger.WriteLine(LOG_IDENT, $"Loaded from {Paths.Process}");
@ -153,7 +165,7 @@ namespace Bloxstrap
ApplicationConfiguration.Initialize(); ApplicationConfiguration.Initialize();
HttpClient.Timeout = TimeSpan.FromSeconds(30); HttpClient.Timeout = TimeSpan.FromSeconds(30);
HttpClient.DefaultRequestHeaders.Add("User-Agent", ProjectRepository); HttpClient.DefaultRequestHeaders.Add("User-Agent", userAgent);
LaunchSettings = new LaunchSettings(e.Args); LaunchSettings = new LaunchSettings(e.Args);

View File

@ -1009,7 +1009,7 @@ namespace Bloxstrap
if (ex.GetType() == typeof(ChecksumFailedException)) if (ex.GetType() == typeof(ChecksumFailedException))
{ {
_ = App.HttpClient.GetAsync($"http://bloxstraplabs.com/metrics/post?key=packageDownloadState&value=httpFail"); _ = App.HttpClient.GetAsync($"https://bloxstraplabs.com/metrics/post?key=packageDownloadState&value=httpFail");
Frontend.ShowConnectivityDialog( Frontend.ShowConnectivityDialog(
Strings.Dialog_Connectivity_UnableToDownload, Strings.Dialog_Connectivity_UnableToDownload,
@ -1044,7 +1044,7 @@ namespace Bloxstrap
if (statIsRetrying) if (statIsRetrying)
{ {
string stat = statIsHttp ? "httpSuccess" : "retrySuccess"; string stat = statIsHttp ? "httpSuccess" : "retrySuccess";
_ = App.HttpClient.GetAsync($"http://bloxstraplabs.com/metrics/post?key=packageDownloadState&value={stat}"); _ = App.HttpClient.GetAsync($"https://bloxstraplabs.com/metrics/post?key=packageDownloadState&value={stat}");
} }
} }

View File

@ -3,7 +3,5 @@
public static class GlobalCache public static class GlobalCache
{ {
public static readonly Dictionary<string, string?> ServerLocation = new(); public static readonly Dictionary<string, string?> ServerLocation = new();
public static readonly Dictionary<long, ThumbnailResponse> UserThumbnails = new();
} }
} }