mirror of
https://github.com/RRQM/TouchSocket.git
synced 2025-12-17 17:06:45 +08:00
重构(Directory.Packages.props, Program.cs): 更新依赖版本并优化代码
更新 TouchSocketVersion 至 4.0.2,重命名 BigDataHttpContent 类字段以统一命名规范,移除无用方法 TryComputeLength,调整 OnBuildingHeader 和 WriteContent 方法逻辑
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
<PropertyGroup>
|
||||
<!-- Enable Central Package Management -->
|
||||
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
|
||||
<TouchSocketVersion>4.0.1</TouchSocketVersion>
|
||||
<TouchSocketVersion>4.0.2</TouchSocketVersion>
|
||||
</PropertyGroup>
|
||||
|
||||
<!-- Centralized Package Version Management -->
|
||||
|
||||
@@ -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<TByteBlock>(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);
|
||||
|
||||
Reference in New Issue
Block a user