更新依赖包。并更新editor到最新版
This commit is contained in:
@@ -6,8 +6,8 @@
|
||||
|
||||
<ItemGroup>
|
||||
<FrameworkReference Include="Microsoft.AspNetCore.App" />
|
||||
<PackageReference Include="NewLife.Core" Version="10.1.2022.1201" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.2" />
|
||||
<PackageReference Include="NewLife.Core" Version="10.2.2023.301" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
||||
<PackageReference Include="PinYinConverterCore" Version="1.0.2" />
|
||||
<PackageReference Include="SkiaSharp" Version="2.88.3" />
|
||||
<PackageReference Include="SkiaSharp.NativeAssets.Linux" Version="2.88.3" />
|
||||
|
||||
+6
-113
@@ -14,6 +14,7 @@ using System.Linq;
|
||||
using System.Net.Sockets;
|
||||
using System.Runtime.InteropServices;
|
||||
using NewLife.Caching;
|
||||
using System.Net.Http;
|
||||
|
||||
namespace COMCMS.Common
|
||||
{
|
||||
@@ -1214,127 +1215,19 @@ namespace COMCMS.Common
|
||||
/// <returns></returns>
|
||||
public static string HttpGet(string url)
|
||||
{
|
||||
HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(url);
|
||||
request.Method = "GET";
|
||||
//request.ContentType = "application/x-www-form-urlencoded";
|
||||
request.Accept = "*/*";
|
||||
request.Proxy = null;
|
||||
request.Timeout = 15000;
|
||||
request.AllowAutoRedirect = false;
|
||||
|
||||
WebResponse response = null;
|
||||
//使用webclient http get
|
||||
string responseStr = null;
|
||||
|
||||
try
|
||||
using (HttpClient client = new HttpClient())
|
||||
{
|
||||
response = request.GetResponse();
|
||||
|
||||
if (response != null)
|
||||
var re = client.GetAsync(url).Result;
|
||||
if (re.IsSuccessStatusCode)
|
||||
{
|
||||
StreamReader reader = new StreamReader(response.GetResponseStream(), Encoding.UTF8);
|
||||
responseStr = reader.ReadToEnd();
|
||||
reader.Close();
|
||||
responseStr = re.Content.ReadAsStringAsync().Result;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
NewLife.Log.XTrace.WriteException(ex);
|
||||
throw;
|
||||
}
|
||||
finally
|
||||
{
|
||||
request = null;
|
||||
response = null;
|
||||
}
|
||||
|
||||
return responseStr;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 后台发送POST请求
|
||||
/// </summary>
|
||||
/// <param name="url">服务器地址</param>
|
||||
/// <param name="data">发送的数据</param>
|
||||
/// <returns></returns>
|
||||
public static Stream HttpPost(string url, string data)
|
||||
{
|
||||
try
|
||||
{
|
||||
//创建post请求
|
||||
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
|
||||
request.Method = "POST";
|
||||
request.ContentType = "application/json;charset=UTF-8";
|
||||
byte[] payload = Encoding.UTF8.GetBytes(data);
|
||||
request.ContentLength = payload.Length;
|
||||
|
||||
|
||||
//发送post的请求
|
||||
Stream writer = request.GetRequestStream();
|
||||
writer.Write(payload, 0, payload.Length);
|
||||
writer.Close();
|
||||
|
||||
//接受返回来的数据
|
||||
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
|
||||
Stream stream = response.GetResponseStream();
|
||||
return stream;
|
||||
//StreamReader reader = new StreamReader(stream, Encoding.UTF8);
|
||||
//string value = reader.ReadToEnd();
|
||||
|
||||
//reader.Close();
|
||||
//stream.Close();
|
||||
//response.Close();
|
||||
|
||||
//return value;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
NewLife.Log.XTrace.WriteException(ex);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 后台发送POST请求
|
||||
/// </summary>
|
||||
/// <param name="url">服务器地址</param>
|
||||
/// <param name="data">发送的数据</param>
|
||||
/// <returns></returns>
|
||||
public static string HttpPostAndReturnString(string url, string data)
|
||||
{
|
||||
try
|
||||
{
|
||||
//创建post请求
|
||||
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
|
||||
request.Method = "POST";
|
||||
request.ContentType = "application/json;charset=UTF-8";
|
||||
byte[] payload = Encoding.UTF8.GetBytes(data);
|
||||
request.ContentLength = payload.Length;
|
||||
|
||||
|
||||
//发送post的请求
|
||||
Stream writer = request.GetRequestStream();
|
||||
writer.Write(payload, 0, payload.Length);
|
||||
writer.Close();
|
||||
|
||||
//接受返回来的数据
|
||||
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
|
||||
Stream stream = response.GetResponseStream();
|
||||
StreamReader reader = new StreamReader(stream, Encoding.UTF8);
|
||||
string value = reader.ReadToEnd();
|
||||
|
||||
reader.Close();
|
||||
stream.Close();
|
||||
response.Close();
|
||||
|
||||
return value;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
NewLife.Log.XTrace.WriteException(ex);
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 将对象转换为Int32类型
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user