|  |  | 
 |  |  | 锘縰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; | 
 |  |  | 
 |  |  |         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 ""; | 
 |  |  |         } | 
 |  |  |     } | 
 |  |  | } |