Skip to content

Commit 9ab37b4

Browse files
committed
up
1 parent f9c1623 commit 9ab37b4

4 files changed

Lines changed: 26 additions & 93 deletions

File tree

ColoryrServer/ASP/HttpClientUtils.cs

Lines changed: 0 additions & 52 deletions
This file was deleted.

ColoryrServer/ASP/Program.cs

Lines changed: 9 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,11 @@
1010
using Lib.Server;
1111
using Microsoft.AspNetCore.Connections;
1212
using Microsoft.Extensions.Primitives;
13+
using Newtonsoft.Json;
1314
using Newtonsoft.Json.Linq;
1415
using System.Collections.Concurrent;
1516
using System.Collections.Specialized;
17+
using System.Diagnostics;
1618
using System.Security.Cryptography.X509Certificates;
1719
using System.Text;
1820
using HttpRequest = Microsoft.AspNetCore.Http.HttpRequest;
@@ -80,10 +82,6 @@ public static void Main()
8082
ServerMain.ConfigUtil = new ASPConfigUtils();
8183
ServerMain.Start();
8284

83-
HttpClients1.Start();
84-
85-
//Web.UseRouting();
86-
8785
if (Config.Ssl)
8886
{
8987
builder.Services.AddCertificateForwarding(options =>
@@ -171,7 +169,6 @@ public static void Main()
171169
Run = false;
172170
ServerMain.LogOut("正在关闭服务器");
173171
ServerMain.Stop();
174-
HttpClients1.Stop();
175172
ServerMain.LogOut("按下回车键退出");
176173
}
177174

@@ -472,6 +469,7 @@ private static async Task POSTBack(HttpContext context)
472469
{
473470
if (Request.ContentType is ServerContentType.POSTXFORM)
474471
{
472+
type = MyContentType.XFormData;
475473
foreach (var item in Request.Form)
476474
{
477475
temp.Add(item.Key, item.Value);
@@ -485,27 +483,6 @@ private static async Task POSTBack(HttpContext context)
485483
{
486484
try
487485
{
488-
//boundary??
489-
//var temp1 = Request.ContentType.Remove(0, ServerContentType.POSTFORMDATA.Length);
490-
//MemoryStream stream = new();
491-
//await Request.Body.CopyToAsync(stream);
492-
//var temp2 = Encoding.UTF8.GetString(stream.ToArray());
493-
//stream.Seek(0, SeekOrigin.Begin);
494-
//var parser = await MultipartFormDataParser.ParseAsync(stream);
495-
//if (parser == null)
496-
//{
497-
// httpReturn = new HttpReturn
498-
// {
499-
// Data = StreamUtils.JsonOBJ(new GetMeesage
500-
// {
501-
// Res = 123,
502-
// Text = "表单解析发生错误"
503-
// })
504-
// };
505-
// await Response.BodyWriter.WriteAsync(httpReturn.Data);
506-
// return;
507-
//}
508-
509486
var parser = await MultipartFormDataParser.ParseAsync(Request.Body);
510487
foreach (var item in parser.Parameters)
511488
{
@@ -521,19 +498,16 @@ private static async Task POSTBack(HttpContext context)
521498
ContentDisposition = item.ContentDisposition
522499
});
523500
}
501+
type = MyContentType.MFormData;
524502
}
525503
catch (Exception e)
526504
{
527505
ServerMain.LogError(e);
528-
httpReturn = new HttpReturn
506+
await Response.WriteAsJsonAsync(new GetMeesage
529507
{
530-
Data = StreamUtils.JsonOBJ(new GetMeesage
531-
{
532-
Res = 123,
533-
Text = "表单解析发生错误,请检查数据"
534-
})
535-
};
536-
await Response.BodyWriter.WriteAsync(httpReturn.Data);
508+
Res = 123,
509+
Text = "表单解析发生错误,请检查数据"
510+
});
537511
return;
538512
}
539513
}
@@ -547,6 +521,7 @@ private static async Task POSTBack(HttpContext context)
547521
{
548522
temp.Add(item.Key, item.Value);
549523
}
524+
type = MyContentType.Json;
550525
}
551526
else
552527
{

ColoryrServer/Core/DllManager/DllRun.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
using System;
77
using System.Collections.Generic;
88
using System.Reflection;
9+
using System.Threading.Tasks;
910

1011
namespace ColoryrServer.DllManager
1112
{

ColoryrServer/Core/ServerMain.cs

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ namespace ColoryrServer
2525
{
2626
public class ServerMain
2727
{
28-
public const string Version = "1.1.0";
28+
public const string Version = "1.1.1";
2929
/// <summary>
3030
/// 配置文件
3131
/// </summary>
@@ -50,8 +50,11 @@ public class ServerMain
5050
public static void LogError(Exception e)
5151
{
5252
string a = "[错误]" + e.ToString();
53-
Task.Run(() => Logs.LogWrite(a));
54-
Console.WriteLine(a);
53+
Task.Run(() =>
54+
{
55+
Logs.LogWrite(a);
56+
Console.WriteLine(a);
57+
});
5558
}
5659
/// <summary>
5760
/// 写错误到日志中
@@ -60,8 +63,11 @@ public static void LogError(Exception e)
6063
public static void LogError(string a)
6164
{
6265
a = "[错误]" + a;
63-
Task.Run(() => Logs.LogWrite(a));
64-
Console.WriteLine(a);
66+
Task.Run(() =>
67+
{
68+
Logs.LogWrite(a);
69+
Console.WriteLine(a);
70+
});
6571
}
6672
/// <summary>
6773
/// 写信息到日志中
@@ -70,8 +76,11 @@ public static void LogError(string a)
7076
public static void LogOut(string a)
7177
{
7278
a = "[信息]" + a;
73-
Task.Run(() => Logs.LogWrite(a));
74-
Console.WriteLine(a);
79+
Task.Run(() =>
80+
{
81+
Logs.LogWrite(a);
82+
Console.WriteLine(a);
83+
});
7584
}
7685

7786
public static void Start()

0 commit comments

Comments
 (0)