From bc8dd1f11f2a5ca6222ccc81a52f3441f7269aba Mon Sep 17 00:00:00 2001 From: rmbgame Date: Sat, 17 Jul 2021 20:34:37 +0800 Subject: [PATCH] Fix --- .../Implementation/HttpProxyServiceImpl.cs | 22 ++++++++++--------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/src/ST.Client/Services/Implementation/HttpProxyServiceImpl.cs b/src/ST.Client/Services/Implementation/HttpProxyServiceImpl.cs index 1a72a408b..20aa51fec 100644 --- a/src/ST.Client/Services/Implementation/HttpProxyServiceImpl.cs +++ b/src/ST.Client/Services/Implementation/HttpProxyServiceImpl.cs @@ -91,21 +91,23 @@ namespace System.Application.Services.Implementation e.Ok(body ?? "500", headrs); return; case "POST": - var requestStream = new StreamWriter(new MemoryStream()); try { if (e.HttpClient.Request.ContentLength > 0) { - requestStream.Write(e.HttpClient.Request.BodyString); - - var send = new HttpRequestMessage + var conext = await IHttpService.Instance.SendAsync(url, () => { - Method = HttpMethod.Post, - Content = new StreamContent(requestStream.BaseStream), - }; - send.Content.Headers.ContentType = MediaTypeHeaderValue.Parse(e.HttpClient.Request.ContentType); - send.Content.Headers.ContentLength = e.HttpClient.Request.BodyString.Length; - var conext = await IHttpService.Instance.SendAsync(url, send, null, false, new CancellationToken()); + using var sw = new MemoryStream().GetWriter(leaveOpen: true); + sw.Write(e.HttpClient.Request.BodyString); + var req = new HttpRequestMessage + { + Method = HttpMethod.Post, + Content = new StreamContent(sw.BaseStream), + }; + req.Content.Headers.ContentType = MediaTypeHeaderValue.Parse(e.HttpClient.Request.ContentType); + req.Content.Headers.ContentLength = e.HttpClient.Request.BodyString.Length; + return req; + }, null, false, new CancellationToken()); e.Ok(conext ?? "500", headrs); } else