about summary refs log tree commit diff
path: root/MatrixRoomUtils.Core/Extensions/HttpClientExtensions.cs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--MatrixRoomUtils.Core/Extensions/HttpClientExtensions.cs19
1 files changed, 19 insertions, 0 deletions
diff --git a/MatrixRoomUtils.Core/Extensions/HttpClientExtensions.cs b/MatrixRoomUtils.Core/Extensions/HttpClientExtensions.cs
new file mode 100644
index 0000000..66a5133
--- /dev/null
+++ b/MatrixRoomUtils.Core/Extensions/HttpClientExtensions.cs
@@ -0,0 +1,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;
+        }
+    }
+}
\ No newline at end of file