初始化代码
This commit is contained in:
27
U8AppMain/HttpHelper.cs
Normal file
27
U8AppMain/HttpHelper.cs
Normal file
@@ -0,0 +1,27 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net.Http;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace U8AppMain
|
||||
{
|
||||
public static class HttpHelper
|
||||
{
|
||||
public static Task<string> Post(string url, string strBody)
|
||||
{
|
||||
strBody = strBody ?? "";
|
||||
using (HttpClient client = new HttpClient())
|
||||
{
|
||||
var httpContent = new StringContent(strBody, Encoding.UTF8);
|
||||
httpContent.Headers.ContentType.MediaType = "application/xml";
|
||||
httpContent.Headers.ContentType.CharSet = "utf-8";
|
||||
HttpResponseMessage response = client.PostAsync(url, httpContent).Result;
|
||||
if (httpContent != null)
|
||||
httpContent.Dispose();
|
||||
return response.Content.ReadAsStringAsync();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user