Fix warnings

This commit is contained in:
pcjones
2024-09-04 19:39:15 +02:00
parent 238bd9cc60
commit 370e3ca06b
8 changed files with 41 additions and 47 deletions

View File

@@ -38,21 +38,19 @@ public static class Helper
private static async Task<IpInfo?> GetPublicIpAddressInfoAsync()
{
using (var client = new HttpClient())
{
client.Timeout = TimeSpan.FromSeconds(10);
using var client = new HttpClient();
client.Timeout = TimeSpan.FromSeconds(10);
try
{
var response = await client.GetAsync("https://ipinfo.io/json");
response.EnsureSuccessStatusCode();
var content = await response.Content.ReadAsStringAsync();
return JsonSerializer.Deserialize<IpInfo>(content);
}
catch
{
return null;
}
try
{
var response = await client.GetAsync("https://ipinfo.io/json");
response.EnsureSuccessStatusCode();
var content = await response.Content.ReadAsStringAsync();
return JsonSerializer.Deserialize<IpInfo>(content);
}
catch
{
return null;
}
}
}