HttpManager.cs 941 B

1234567891011121314151617181920212223242526272829
  1. using BHJD.DBdll.Public;
  2. using Cysharp.Threading.Tasks;
  3. namespace SimulationServer.Utils;
  4. public class HttpManager
  5. {
  6. public static async UniTask<string> Post(string url, string json)
  7. {
  8. HttpClient client = new HttpClient();
  9. HttpContent content = new StringContent(json);
  10. content.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue("application/json");
  11. HttpResponseMessage response = await client.PostAsync(url, content);
  12. return await response.Content.ReadAsStringAsync();
  13. }
  14. public static string Get(string url, List<string> key,List<string> value)
  15. {
  16. IHttpHelper.HttpCmd type = new IHttpHelper.HttpCmd
  17. {
  18. m_RequestType = IHttpHelper.HttpRequestType.GET,
  19. m_Addr = url,
  20. m_Args = key
  21. };
  22. HttpHelper httpHelper = new HttpHelper();
  23. return httpHelper.Request(type, value);
  24. }
  25. }