1010using Lib . Server ;
1111using Microsoft . AspNetCore . Connections ;
1212using Microsoft . Extensions . Primitives ;
13+ using Newtonsoft . Json ;
1314using Newtonsoft . Json . Linq ;
1415using System . Collections . Concurrent ;
1516using System . Collections . Specialized ;
17+ using System . Diagnostics ;
1618using System . Security . Cryptography . X509Certificates ;
1719using System . Text ;
1820using 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 {
0 commit comments