HttpClientExtensions.cs (507B)
1 namespace MatrixRoomUtils.Core.Extensions; 2 3 public static class HttpClientExtensions 4 { 5 public static async Task<bool> CheckSuccessStatus(this HttpClient hc, string url) 6 { 7 //cors causes failure, try to catch 8 try 9 { 10 var resp = await hc.GetAsync(url); 11 return resp.IsSuccessStatusCode; 12 } 13 catch (Exception e) 14 { 15 Console.WriteLine($"Failed to check success status: {e.Message}"); 16 return false; 17 } 18 } 19 }