From 54febd14b46858f6024cda876a5b06cee179179c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8B=A5=E6=B1=9D=E6=A3=8B=E8=8C=97?= <505554090@qq.com> Date: Sat, 6 Dec 2025 15:25:15 +0800 Subject: [PATCH] =?UTF-8?q?=E9=87=8D=E6=9E=84(Directory.Packages.props,=20?= =?UTF-8?q?Program.cs):=20=E6=9B=B4=E6=96=B0=E4=BE=9D=E8=B5=96=E7=89=88?= =?UTF-8?q?=E6=9C=AC=E5=B9=B6=E4=BC=98=E5=8C=96=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 更新 TouchSocketVersion 至 4.0.2,重命名 BigDataHttpContent 类字段以统一命名规范,移除无用方法 TryComputeLength,调整 OnBuildingHeader 和 WriteContent 方法逻辑 --- examples/Directory.Packages.props | 2 +- examples/Http/HttpClientConsoleApp/Program.cs | 17 +++++------------ 2 files changed, 6 insertions(+), 13 deletions(-) diff --git a/examples/Directory.Packages.props b/examples/Directory.Packages.props index 1497e3812..6be945142 100644 --- a/examples/Directory.Packages.props +++ b/examples/Directory.Packages.props @@ -2,7 +2,7 @@ true - 4.0.1 + 4.0.2 diff --git a/examples/Http/HttpClientConsoleApp/Program.cs b/examples/Http/HttpClientConsoleApp/Program.cs index bfee84c6f..e37fb29c6 100644 --- a/examples/Http/HttpClientConsoleApp/Program.cs +++ b/examples/Http/HttpClientConsoleApp/Program.cs @@ -319,8 +319,8 @@ internal class Program internal class BigDataHttpContent : HttpContent { - private readonly long count = 10000; - private readonly long bufferLength = 1000000; + private readonly long m_count = 10000; + private readonly long m_bufferLength = 1000000; protected override bool OnBuildingContent(ref TByteBlock byteBlock) { @@ -329,20 +329,13 @@ internal class BigDataHttpContent : HttpContent protected override void OnBuildingHeader(IHttpHeader header) { - //header.Add(HttpHeaders.ContentLength, (this.count * this.bufferLength).ToString()); + header.Add(HttpHeaders.ContentLength, (this.m_count * this.m_bufferLength).ToString()); } - protected override bool TryComputeLength(out long length) - { - length = this.count * this.bufferLength; - return true; - } - - protected override async Task WriteContent(PipeWriter writer, CancellationToken cancellationToken) { - var buffer = new byte[this.bufferLength]; - for (var i = 0; i < this.count; i++) + var buffer = new byte[this.m_bufferLength]; + for (var i = 0; i < this.m_count; i++) { await writer.WriteAsync(buffer, cancellationToken); //Console.WriteLine(i);