XFE Git
XFE Studio Git
Git 首页 全局搜索
XFE 主站 文档 NuGet
公开
关注 0 Fork 0 Star 0
UTF-8
using System.Net;
using System.Net.Http;

namespace SpaceEngineersBlueprintEditor.Installer.Utilities;

public static class DownloadHelper
{
    /// <summary>
    /// 获取服务器响应
    /// </summary>
    /// <param name="postBody">响应体</param>
    /// <returns></returns>
    public static async Task<(string, HttpStatusCode)> GetServerResponse(string postBody, string requestAddress)
    {
        using var client = new HttpClient();
        var result = await client.PostAsync(requestAddress, new StringContent(postBody));
        try
        {
            return (await result.Content.ReadAsStringAsync(), result.StatusCode);
        }
        catch (Exception ex)
        {
            return (ex.Message, result.StatusCode);
        }
    }
}