From 33daa0c94b5c48d0da195268f3ad34ea5511cbd3 Mon Sep 17 00:00:00 2001 From: mmmray <142015632+mmmray@users.noreply.github.com> Date: Mon, 29 Jul 2024 10:50:59 +0200 Subject: [PATCH] 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. --- transport/internet/splithttp/config.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/transport/internet/splithttp/config.go b/transport/internet/splithttp/config.go index 8bb61746..7f2dc3f5 100644 --- a/transport/internet/splithttp/config.go +++ b/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,