about summary refs log tree commit diff
path: root/MatrixRoomUtils.Core/Extensions/HttpClientExtensions.cs
blob: 66a5133503e686580a7529c1b4353f2fe117ec7b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
namespace MatrixRoomUtils.Extensions;

public static class HttpClientExtensions
{
    public static async Task<bool> CheckSuccessStatus(this HttpClient hc, string url)
    {
        //cors causes failure, try to catch
        try
        {
            var resp = await hc.GetAsync(url);
            return resp.IsSuccessStatusCode;
        }
        catch (Exception e)
        {
            Console.WriteLine($"Failed to check success status: {e.Message}");
            return false;
        }
    }
}