diff --git a/Bloxstrap/App.xaml.cs b/Bloxstrap/App.xaml.cs index 8d93a46e..065c2203 100644 --- a/Bloxstrap/App.xaml.cs +++ b/Bloxstrap/App.xaml.cs @@ -46,15 +46,15 @@ public partial class App : Application public static bool IsMenuLaunch { get; private set; } = false; public static string[] LaunchArgs { get; private set; } = null!; - public static BuildMetadataAttribute BuildMetadata => Assembly.GetExecutingAssembly().GetCustomAttribute()!; + public static BuildMetadataAttribute BuildMetadata = Assembly.GetExecutingAssembly().GetCustomAttribute()!; public static string Version = Assembly.GetExecutingAssembly().GetName().Version!.ToString()[..^2]; - // singletons public static readonly Logger Logger = new(); + public static readonly HttpClient HttpClient = new(new HttpClientLoggingHandler(new HttpClientHandler { AutomaticDecompression = DecompressionMethods.All })); + public static readonly JsonManager Settings = new(); public static readonly JsonManager State = new(); public static readonly FastFlagManager FastFlags = new(); - public static readonly HttpClient HttpClient = new(new HttpClientHandler { AutomaticDecompression = DecompressionMethods.All }); public static System.Windows.Forms.NotifyIcon Notification { get; private set; } = null!; diff --git a/Bloxstrap/HttpClientLoggingHandler.cs b/Bloxstrap/HttpClientLoggingHandler.cs new file mode 100644 index 00000000..ccf7bd28 --- /dev/null +++ b/Bloxstrap/HttpClientLoggingHandler.cs @@ -0,0 +1,31 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Net; +using System.Net.Http; +using System.Text; +using System.Threading; +using System.Threading.Tasks; + +namespace Bloxstrap +{ + internal class HttpClientLoggingHandler : MessageProcessingHandler + { + public HttpClientLoggingHandler(HttpMessageHandler innerHandler) + : base(innerHandler) + { + } + + protected override HttpRequestMessage ProcessRequest(HttpRequestMessage request, CancellationToken cancellationToken) + { + App.Logger.WriteLine($"[HttpClientLoggingHandler::HttpRequestMessage] {request.Method} {request.RequestUri}"); + return request; + } + + protected override HttpResponseMessage ProcessResponse(HttpResponseMessage response, CancellationToken cancellationToken) + { + App.Logger.WriteLine($"[HttpClientLoggingHandler::HttpResponseMessage] {(int)response.StatusCode} {response.ReasonPhrase} {response.RequestMessage!.RequestUri}"); + return response; + } + } +} diff --git a/Bloxstrap/RobloxDeployment.cs b/Bloxstrap/RobloxDeployment.cs index 69390ccf..dc597f1c 100644 --- a/Bloxstrap/RobloxDeployment.cs +++ b/Bloxstrap/RobloxDeployment.cs @@ -110,8 +110,6 @@ public static async Task GetInfo(string channel, bool timestamp = throw new Exception($"Could not get latest deploy for channel {channel}! (HTTP {deployInfoResponse.StatusCode})"); } - App.Logger.WriteLine($"[RobloxDeployment::GetInfo] Got JSON: {rawResponse}"); - ClientVersion clientVersion = JsonSerializer.Deserialize(rawResponse)!; // for preferences diff --git a/Bloxstrap/UI/ExceptionDialog.xaml b/Bloxstrap/UI/ExceptionDialog.xaml index b047297e..218142e5 100644 --- a/Bloxstrap/UI/ExceptionDialog.xaml +++ b/Bloxstrap/UI/ExceptionDialog.xaml @@ -38,9 +38,9 @@