This commit is contained in:
2025-09-16 10:42:51 +01:00
parent 50bb9c9781
commit 0c463ad929
8 changed files with 351 additions and 200 deletions

View File

@@ -12,7 +12,7 @@ namespace AiQ_GUI
public static void Initialize(string username, string password)
{
HttpClientHandler handler = new HttpClientHandler
HttpClientHandler handler = new()
{
MaxConnectionsPerServer = 25,
Credentials = new NetworkCredential(username, password)
@@ -30,7 +30,7 @@ namespace AiQ_GUI
{
try
{
HttpRequestMessage request = new HttpRequestMessage(method, url);
HttpRequestMessage request = new(method, url);
if (jsonData != null) // Fills in the body of the request if jsonData is provided
request.Content = new StringContent(jsonData, Encoding.UTF8, "application/json");
@@ -48,8 +48,8 @@ namespace AiQ_GUI
}
}
int timeoutMs = (Timeout ?? 10) * 1000; // Convert from seconds to ms
using CancellationTokenSource cts = new CancellationTokenSource(timeoutMs);
int timeoutMs = (Timeout ?? 10) * 1000; // Convert from seconds to ms, default to 10s if null
using CancellationTokenSource cts = new(timeoutMs);
using HttpResponseMessage response = await Client.SendAsync(request, HttpCompletionOption.ResponseHeadersRead, cts.Token);
response.EnsureSuccessStatusCode();