Miscellaneous HTTP/task improvements

This commit is contained in:
pizzaboxer 2023-07-29 20:35:36 +01:00
parent cb19366db9
commit 3a826519fe
No known key found for this signature in database
GPG Key ID: 59D4A1DBAD0F2BA8
2 changed files with 9 additions and 7 deletions

View File

@ -41,7 +41,11 @@ namespace Bloxstrap
public static readonly JsonManager<State> State = new();
public static readonly FastFlagManager FastFlags = new();
public static readonly HttpClient HttpClient = new(new HttpClientLoggingHandler(new HttpClientHandler { AutomaticDecompression = DecompressionMethods.All }));
public static readonly HttpClient HttpClient = new(
new HttpClientLoggingHandler(
new HttpClientHandler { AutomaticDecompression = DecompressionMethods.All }
)
);
public static void Terminate(ErrorCode exitCode = ErrorCode.ERROR_SUCCESS)
{
@ -107,7 +111,7 @@ namespace Bloxstrap
LaunchArgs = e.Args;
HttpClient.Timeout = TimeSpan.FromMinutes(5);
HttpClient.Timeout = TimeSpan.FromSeconds(30);
HttpClient.DefaultRequestHeaders.Add("User-Agent", ProjectRepository);
if (LaunchArgs.Length > 0)
@ -295,9 +299,7 @@ namespace Bloxstrap
}
}
Task bootstrapperTask = Task.Run(() => bootstrapper.Run());
bootstrapperTask.ContinueWith(t =>
Task bootstrapperTask = Task.Run(() => bootstrapper.Run()).ContinueWith(t =>
{
Logger.WriteLine(LOG_IDENT, "Bootstrapper task has finished");

View File

@ -9,13 +9,13 @@
protected override HttpRequestMessage ProcessRequest(HttpRequestMessage request, CancellationToken cancellationToken)
{
App.Logger.WriteLine("HttpClientLoggingHandler::HttpRequestMessage", $"{request.Method} {request.RequestUri}");
App.Logger.WriteLine("HttpClientLoggingHandler::ProcessRequest", $"{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}");
App.Logger.WriteLine("HttpClientLoggingHandler::ProcessResponse", $"{(int)response.StatusCode} {response.ReasonPhrase} {response.RequestMessage!.RequestUri}");
return response;
}
}