|
|
@@ -7,16 +7,6 @@ using System.Threading.Tasks;
|
|
|
namespace Business.Core.Utilities
|
|
|
{
|
|
|
public class HttpHelper
|
|
|
- {/// <summary>
|
|
|
- /// 发起POST同步请求
|
|
|
- ///
|
|
|
- /// </summary>
|
|
|
- /// <param name="url"></param>
|
|
|
- /// <param name="postData"></param>
|
|
|
- /// <param name="contentType">application/xml、application/json、application/text、application/x-www-form-urlencoded</param>
|
|
|
- /// <param name="headers">填充消息头</param>
|
|
|
- /// <returns></returns>
|
|
|
- public static string HttpPost(string url, string postData = null, string contentType = null, int timeOut = 30, Dictionary<string, string> headers = null)
|
|
|
{
|
|
|
public static string HttpGet(string url, Dictionary<string, string>? headers = null)
|
|
|
{
|
|
|
@@ -27,13 +17,6 @@ namespace Business.Core.Utilities
|
|
|
{
|
|
|
client.DefaultRequestHeaders.Add(header.Key, header.Value);
|
|
|
}
|
|
|
- using (HttpContent httpContent = new StringContent(postData, Encoding.UTF8))
|
|
|
- {
|
|
|
- if (contentType != null)
|
|
|
- httpContent.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue(contentType);
|
|
|
-
|
|
|
- HttpResponseMessage response = client.PostAsync(url, httpContent).Result;
|
|
|
- return response.Content.ReadAsStringAsync().Result;
|
|
|
}
|
|
|
try
|
|
|
{
|
|
|
@@ -55,9 +38,6 @@ namespace Business.Core.Utilities
|
|
|
{
|
|
|
client.DefaultRequestHeaders.Add(header.Key, header.Value);
|
|
|
}
|
|
|
- HttpResponseMessage response = client.GetAsync(url).Result;
|
|
|
- return response.Content.ReadAsStringAsync().Result;
|
|
|
- }
|
|
|
}
|
|
|
HttpContent content = new StringContent(postData ?? "", encoding ?? Encoding.UTF8);
|
|
|
if (!string.IsNullOrWhiteSpace(contentType))
|