|
@@ -2,6 +2,7 @@
|
|
|
using Aspose.Words;
|
|
|
using Aspose.Words.Drawing;
|
|
|
using Aspose.Words.Tables;
|
|
|
+using EyeSoft.IO;
|
|
|
using Microsoft.AspNetCore.SignalR;
|
|
|
using MySqlX.XDevAPI.Relational;
|
|
|
using NPOI.HSSF.UserModel;
|
|
@@ -33,6 +34,8 @@ using System.Data;
|
|
|
using System.Diagnostics;
|
|
|
using System.Globalization;
|
|
|
using System.IO;
|
|
|
+using System.IO.Compression;
|
|
|
+using System.Net.Http;
|
|
|
using System.Reflection.PortableExecutable;
|
|
|
using Ubiety.Dns.Core;
|
|
|
using static OASystem.API.OAMethodLib.JWTHelper;
|
|
@@ -15065,8 +15068,8 @@ And (UnitName != '' Or UnitName != null) {sqlWhere}");
|
|
|
string url = param["url"]!.ToString();
|
|
|
var methon = "get";
|
|
|
|
|
|
- Dictionary<string, string> bodyValues = null;
|
|
|
Dictionary<string, string> headValues = null;
|
|
|
+ string bodyStr = string.Empty;
|
|
|
|
|
|
if (param.ContainsKey("methon"))
|
|
|
{
|
|
@@ -15086,27 +15089,26 @@ And (UnitName != '' Or UnitName != null) {sqlWhere}");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- if (param.ContainsKey("body"))
|
|
|
- {
|
|
|
- var body = param["body"]!.ToString();
|
|
|
- bodyValues = new Dictionary<string, string>();
|
|
|
- JObject bodyJobject = JObject.Parse(body);
|
|
|
- foreach (JProperty item in bodyJobject.Properties())
|
|
|
- {
|
|
|
- var value = item.Value.ToString();
|
|
|
- var head = item.Path;
|
|
|
- bodyValues.Add(head, value);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
HttpClient client = new HttpClient();
|
|
|
string responseString = string.Empty;
|
|
|
+ StringContent content = null;
|
|
|
|
|
|
if (headValues != null)
|
|
|
{
|
|
|
foreach (var item in headValues.Keys)
|
|
|
{
|
|
|
- client.DefaultRequestHeaders.Add(item, headValues[item]);
|
|
|
+ if (item.ToLower().Contains("content") && item.ToLower().Contains("type"))
|
|
|
+ {
|
|
|
+ if (param.ContainsKey("body"))
|
|
|
+ {
|
|
|
+ bodyStr = param["body"]!.ToString();
|
|
|
+ }
|
|
|
+ content = new StringContent(bodyStr, Encoding.UTF8, headValues[item]);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ client.DefaultRequestHeaders.Add(item, headValues[item]);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -15119,18 +15121,29 @@ And (UnitName != '' Or UnitName != null) {sqlWhere}");
|
|
|
}
|
|
|
else if (methon == "post")
|
|
|
{
|
|
|
+ var request = new HttpRequestMessage(HttpMethod.Post, url)
|
|
|
+ {
|
|
|
+ Content = content
|
|
|
+ };
|
|
|
+ var response = await client.SendAsync(request);
|
|
|
|
|
|
- if (bodyValues == null)
|
|
|
+ try
|
|
|
{
|
|
|
- jw.Msg = "methon post body null";
|
|
|
- return Ok(jw);
|
|
|
+ Stream responseStream = await response.Content.ReadAsStreamAsync();
|
|
|
+
|
|
|
+ using (GZipStream gzipStream = new GZipStream(responseStream, CompressionMode.Decompress))
|
|
|
+ {
|
|
|
+ using (StreamReader reader = new StreamReader(gzipStream))
|
|
|
+ {
|
|
|
+ responseString = await reader.ReadToEndAsync();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ catch (Exception)
|
|
|
+ {
|
|
|
+ responseString = await response.Content.ReadAsStringAsync();
|
|
|
}
|
|
|
|
|
|
- // 数据转化为 key=val 格式
|
|
|
- var content = new FormUrlEncodedContent(bodyValues);
|
|
|
- var response = await client.PostAsync(url, content);
|
|
|
- // 获取数据
|
|
|
- responseString = await response.Content.ReadAsStringAsync();
|
|
|
}
|
|
|
else
|
|
|
{
|