From dfc3591e89e7d263f32c9add9654a552113b39ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8C=BF=E4=BA=BA=E6=98=93?= Date: Thu, 19 Dec 2024 19:29:51 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=20HTTP=20=E8=AF=B7=E6=B1=82?= =?UTF-8?q?=E5=A4=84=E7=90=86=E6=80=A7=E8=83=BD=E5=92=8C=E8=B5=84=E6=BA=90?= =?UTF-8?q?=E5=88=A9=E7=94=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 在 `DHWeb.cs` 文件中的 `DHWeb` 类中,增加了以下代码: * `ServicePointManager.ReusePort = true;` // 允许不同的 HTTP 请求重用相同的本地端口。 * `ServicePointManager.Expect100Continue = false;` // 禁用 100-Continue 行为,可能会提高性能。 这些更改通过设置 `ServicePointManager.ReusePort` 和 `ServicePointManager.Expect100Continue` 属性,优化了 HTTP 请求的处理性能和资源利用。 --- Pek.AspNetCore/Helpers/DHWeb.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Pek.AspNetCore/Helpers/DHWeb.cs b/Pek.AspNetCore/Helpers/DHWeb.cs index 5ac1139..630bb09 100644 --- a/Pek.AspNetCore/Helpers/DHWeb.cs +++ b/Pek.AspNetCore/Helpers/DHWeb.cs @@ -32,6 +32,10 @@ static DHWeb() { Environment = Pek.Webs.HttpContext.Current.RequestServices.GetService(); ServicePointManager.DefaultConnectionLimit = 10000000; // 用来限制客户端请求的并发最大连接数 + + ServicePointManager.ReusePort = true; // 可以让不同的HTTP请求重用相同的本地端口。 + + ServicePointManager.Expect100Continue = false; // 询问服务器是否愿意接受数据,禁用此选项可能会提高性能。 } catch {