From 7a589fec185c825d587d9931a5421676e92be1fc Mon Sep 17 00:00:00 2001 From: xfy Date: Fri, 17 Apr 2026 15:02:50 +0800 Subject: [PATCH] =?UTF-8?q?fix(config):=20=E8=AE=BE=E7=BD=AE=20ClientMaxBo?= =?UTF-8?q?dySize=20=E9=BB=98=E8=AE=A4=E5=80=BC=E5=B9=B6=E4=BD=BF=E9=85=8D?= =?UTF-8?q?=E7=BD=AE=E7=94=9F=E6=88=90=E4=BD=BF=E7=94=A8=E8=AF=A5=E5=80=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 将 ClientMaxBodySize 默认值设为 10MB(而非空值) - 修改 GenerateConfigYAML 使用实际配置值而非硬编码的 1MB - 使默认配置与生成配置保持一致 Co-Authored-By: Claude Opus 4.7 --- internal/config/defaults.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/internal/config/defaults.go b/internal/config/defaults.go index 2d2a125..e2d20cc 100644 --- a/internal/config/defaults.go +++ b/internal/config/defaults.go @@ -45,6 +45,7 @@ func DefaultConfig() *Config { IdleTimeout: 120 * time.Second, MaxConnsPerIP: 1000, MaxRequestsPerConn: 10000, + ClientMaxBodySize: "10MB", // 高并发优化配置默认值 Concurrency: 256 * 1024, // 256K 最大并发连接 ReadBufferSize: 16 * 1024, // 16KB 读缓冲 @@ -267,7 +268,7 @@ func GenerateConfigYAML(cfg *Config) ([]byte, error) { fmt.Fprintf(&buf, " idle_timeout: %ds # 空闲超时(0 表示不限制)\n", int(cfg.Servers[0].IdleTimeout.Seconds())) fmt.Fprintf(&buf, " max_conns_per_ip: %d # 每 IP 最大连接数(0 表示不限制)\n", cfg.Servers[0].MaxConnsPerIP) fmt.Fprintf(&buf, " max_requests_per_conn: %d # 每连接最大请求数(0 表示不限制)\n", cfg.Servers[0].MaxRequestsPerConn) - fmt.Fprintf(&buf, " client_max_body_size: \"1MB\" # 请求体大小限制(支持单位: b, kb, mb, gb)\n") + fmt.Fprintf(&buf, " client_max_body_size: \"%s\" # 请求体大小限制(支持单位: b, kb, mb, gb)\n", cfg.Servers[0].ClientMaxBodySize) buf.WriteString(" # 高并发优化配置(可选,未配置时使用默认值)\n") fmt.Fprintf(&buf, " # concurrency: %d # 最大并发连接数(默认 %d)\n", cfg.Servers[0].Concurrency, cfg.Servers[0].Concurrency) fmt.Fprintf(&buf, " # read_buffer_size: %d # 读缓冲区大小(字节,默认 %d)\n", cfg.Servers[0].ReadBufferSize, cfg.Servers[0].ReadBufferSize)