From 84da94c3f22b82d08fe13cbc1713f16ffc1b8fa9 Mon Sep 17 00:00:00 2001 From: pizzaboxer Date: Mon, 30 Sep 2024 10:08:41 +0100 Subject: [PATCH] Update HttpClient user agent format TIL user agents have a specific syntax lol --- Bloxstrap/App.xaml.cs | 14 +++++++++++++- Bloxstrap/Bootstrapper.cs | 4 ++-- Bloxstrap/GlobalCache.cs | 2 -- 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/Bloxstrap/App.xaml.cs b/Bloxstrap/App.xaml.cs index 2da5155..82a5310 100644 --- a/Bloxstrap/App.xaml.cs +++ b/Bloxstrap/App.xaml.cs @@ -141,10 +141,22 @@ namespace Bloxstrap Logger.WriteLine(LOG_IDENT, $"Starting {ProjectName} v{Version}"); + string userAgent = $"{ProjectName}/{Version}"; + if (IsActionBuild) + { 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 + { Logger.WriteLine(LOG_IDENT, $"Compiled {BuildMetadata.Timestamp.ToFriendlyString()} from {BuildMetadata.Machine}"); + userAgent += $" (Build {BuildMetadata.Machine})"; + } Logger.WriteLine(LOG_IDENT, $"Loaded from {Paths.Process}"); @@ -153,7 +165,7 @@ namespace Bloxstrap ApplicationConfiguration.Initialize(); HttpClient.Timeout = TimeSpan.FromSeconds(30); - HttpClient.DefaultRequestHeaders.Add("User-Agent", ProjectRepository); + HttpClient.DefaultRequestHeaders.Add("User-Agent", userAgent); LaunchSettings = new LaunchSettings(e.Args); diff --git a/Bloxstrap/Bootstrapper.cs b/Bloxstrap/Bootstrapper.cs index a28ce22..0f569d1 100644 --- a/Bloxstrap/Bootstrapper.cs +++ b/Bloxstrap/Bootstrapper.cs @@ -1009,7 +1009,7 @@ namespace Bloxstrap 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( Strings.Dialog_Connectivity_UnableToDownload, @@ -1044,7 +1044,7 @@ namespace Bloxstrap if (statIsRetrying) { 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}"); } } diff --git a/Bloxstrap/GlobalCache.cs b/Bloxstrap/GlobalCache.cs index fe28cc0..6977224 100644 --- a/Bloxstrap/GlobalCache.cs +++ b/Bloxstrap/GlobalCache.cs @@ -3,7 +3,5 @@ public static class GlobalCache { public static readonly Dictionary ServerLocation = new(); - - public static readonly Dictionary UserThumbnails = new(); } }