浏览代码

SplitHTTP: Fix wrong config deserialization (#3610)

Testing was conducted only using explicit parameters, and using
testsuite. However, when the parameters are not explicitly set in JSON
config, it seems that `c.MaxUploadSize` will contain `RandRangeConfig {
From: 0, To: 0 }` instead of `nil`, which breaks upload entirely.
mmmray 1 年之前
父节点
当前提交
33daa0c94b
共有 1 个文件被更改,包括 3 次插入3 次删除
  1. 3 3
      transport/internet/splithttp/config.go

+ 3 - 3
transport/internet/splithttp/config.go

@@ -37,7 +37,7 @@ func (c *Config) GetRequestHeader() http.Header {
 }
 
 func (c *Config) GetNormalizedMaxConcurrentUploads(isServer bool) RandRangeConfig {
-	if c.MaxConcurrentUploads == nil {
+	if c.MaxConcurrentUploads == nil || c.MaxConcurrentUploads.To == 0 {
 		if isServer {
 			return RandRangeConfig{
 				From: 200,
@@ -55,7 +55,7 @@ func (c *Config) GetNormalizedMaxConcurrentUploads(isServer bool) RandRangeConfi
 }
 
 func (c *Config) GetNormalizedMaxUploadSize(isServer bool) RandRangeConfig {
-	if c.MaxUploadSize == nil {
+	if c.MaxUploadSize == nil || c.MaxUploadSize.To == 0 {
 		if isServer {
 			return RandRangeConfig{
 				From: 2000000,
@@ -73,7 +73,7 @@ func (c *Config) GetNormalizedMaxUploadSize(isServer bool) RandRangeConfig {
 }
 
 func (c *Config) GetNormalizedMinUploadInterval() RandRangeConfig {
-	if c.MinUploadIntervalMs == nil {
+	if c.MinUploadIntervalMs == nil || c.MinUploadIntervalMs.To == 0 {
 		return RandRangeConfig{
 			From: 30,
 			To:   30,