mirror of
https://github.com/9ParsonsB/Pulsar.git
synced 2025-07-03 01:03:41 -04:00
feat: update check
This commit is contained in:
36
ObservatoryCore/UI/HttpClient.cs
Normal file
36
ObservatoryCore/UI/HttpClient.cs
Normal file
@ -0,0 +1,36 @@
|
||||
using System;
|
||||
using System.Net.Http;
|
||||
|
||||
namespace Observatory
|
||||
{
|
||||
public sealed class HttpClient
|
||||
{
|
||||
private HttpClient()
|
||||
{ }
|
||||
|
||||
private static readonly Lazy<System.Net.Http.HttpClient> lazy = new Lazy<System.Net.Http.HttpClient>(() => new System.Net.Http.HttpClient());
|
||||
|
||||
public static System.Net.Http.HttpClient Client
|
||||
{
|
||||
get
|
||||
{
|
||||
return lazy.Value;
|
||||
}
|
||||
}
|
||||
|
||||
public static string GetString(string url)
|
||||
{
|
||||
return lazy.Value.GetStringAsync(url).Result;
|
||||
}
|
||||
|
||||
public static HttpResponseMessage SendRequest(HttpRequestMessage request)
|
||||
{
|
||||
return lazy.Value.SendAsync(request).Result;
|
||||
}
|
||||
|
||||
public static System.Threading.Tasks.Task<HttpResponseMessage> SendRequestAsync(HttpRequestMessage request)
|
||||
{
|
||||
return lazy.Value.SendAsync(request);
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user