From 0d453df0e07ec3ada05a53640a35df92f27d4f3e Mon Sep 17 00:00:00 2001
From: dengjunjie <dengjunjie@hnkhzn.com>
Date: 星期六, 11 一月 2025 14:56:12 +0800
Subject: [PATCH] 1
---
代码管理/WMS/WIDESEA_WMSServer/WIDESEA_Core/Middlewares/ApiLogMiddleware.cs | 37 +++++++++++++++++++++++--------------
1 files changed, 23 insertions(+), 14 deletions(-)
diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_Core/Middlewares/ApiLogMiddleware.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_Core/Middlewares/ApiLogMiddleware.cs"
index e576b3d..a6c169c 100644
--- "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_Core/Middlewares/ApiLogMiddleware.cs"
+++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_Core/Middlewares/ApiLogMiddleware.cs"
@@ -1,6 +1,7 @@
锘縰sing Microsoft.AspNetCore.Http;
using Microsoft.Extensions.Logging;
using Newtonsoft.Json;
+using Org.BouncyCastle.Asn1.Ocsp;
using System;
using System.Collections.Generic;
using System.Linq;
@@ -83,28 +84,36 @@
private string RequestDataLog(HttpContext context)
{
var request = context.Request;
- var sr = new StreamReader(request.Body);
-
- object obj = new
+ if (request.ContentType?.ToLower() != "multipart/form-data" && request.ContentLength <= 100000)
{
- QueryString = request.QueryString.ToString(),
- BodyData = sr.ReadToEndAsync().Result
- };
+ var sr = new StreamReader(request.Body);
- string data = JsonConvert.SerializeObject(obj);
+ object obj = new
+ {
+ QueryString = request.QueryString.ToString(),
+ BodyData = sr.ReadToEndAsync().Result
+ };
- request.Body.Position = 0;
+ string data = JsonConvert.SerializeObject(obj);
- return data;
+ request.Body.Position = 0;
+
+ return data;
+ }
+ return "";
}
private string ResponseDataLog(HttpResponse response)
{
- response.Body.Position = 0;
- using StreamReader stream = new StreamReader(response.Body, leaveOpen: true);
- string body = stream.ReadToEnd();
- response.Body.Position = 0;
- return body;
+ if (response.ContentType?.ToLower() != "multipart/form-data" && response.ContentLength <= 100000)
+ {
+ response.Body.Position = 0;
+ using StreamReader stream = new StreamReader(response.Body, leaveOpen: true);
+ string body = stream.ReadToEnd();
+ response.Body.Position = 0;
+ return body;
+ }
+ return "";
}
}
}
--
Gitblit v1.9.3